Oct 22, 2012, 8:33 PM
Ext 1.x to 2.x - DirectMethod - ViewState, ViewStateMode
In Ext v1.x we have direct methods and direct events, on the same page, where we alter the ViewState object. For example:
What would be the proper way to handle this situation? Is there a setting or attribute I'm missing?
[DirectMethod(ViewStateMode=ViewStateMode.Enabled)]
public void DoThis()
{
ViewState.Add("MyKey", "Data");
}
protected void DoThat(object sender, DirectEventArgs e)
{
ViewState.Add("MyKey", "Data2");
}
It appears in Ext v2.x, this is not possible with direct methods as an error is generated when building the application with the code above:Error 9 An object reference is required for the non-static field, method, or property 'System.Web.UI.Control.ViewStateMode.get' C:\stuff1\stuff2\test\main.aspx.cs 201 37 test
Removing "(ViewStateMode=ViewStateMode.Enabled)" takes care of the compilation, but trying to access the value from ViewState always returns whatever value we set in the direct event "DoThat" in this case. I have tampered with the page's ResourceManager, setting DisableViewState="false". Also I've tried using ViewStateMode="Enabled" for controls that are used in direct methods but there seems to be no affect.What would be the proper way to handle this situation? Is there a setting or attribute I'm missing?