Ext 1.x to 2.x - DirectMethod - ViewState, ViewStateMode

  1. #1

    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:

    [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?
  2. #2
    1. Set DisableViewState="false" for ResourceManager
    2. Use Ext.Net.ViewStateMode.Enabled instead ViewStateMode.Enabled otherwise compilator will use 'System.Web.UI.ViewStateMode'

Similar Threads

  1. [CLOSED] Difference between DirectMethod , DirectEvent, Static DirectMethod
    By syllabusarq in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 01, 2011, 11:37 AM
  2. Replies: 3
    Last Post: Jul 27, 2010, 7:54 PM
  3. [CLOSED] DirectMethod without Viewstate
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Feb 24, 2010, 5:05 PM
  4. Can't get rid of viewstate
    By jchau in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Nov 13, 2008, 1:25 PM
  5. Replies: 0
    Last Post: Nov 04, 2008, 11:25 AM

Tags for this Thread

Posting Permissions