locked
for which server side control's state are maintain through viewstate RRS feed

  • Question

  • User88744855 posted

    1) asp.net has many server side controls. so just tell me which control's state are maintain through viewstate.

    2) without viewstate how can i maintain control and page state. if possible give answer with example and sample code for question number 2. thanks

    Friday, February 1, 2013 8:29 AM

Answers

  • User-861818263 posted

    When you submit a form to a server, the browser always send the field values
    (those who are named, not disabled and inside the form) to the server. This
    is how a HTML form works "by design".

    The "viewstate" is just an hidden field added by ASP.NET to store extra
    informations and carry them over accross multiple server side executions of
    the same page. It doesn't contains field values.

    When you make enableviewstate=true then textbox values will be sotered in viewstate.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 8, 2013 3:44 AM

All replies

  • User-861818263 posted

    Viewstate

    Viewstate is a hidden fields in an ASP.NET page, contains state of those controls on a page whose “EnableViewstate” property is “true”.

    You can also explicitly add values in it, on an ASP.NET page like:

    Viewstate.Add( “TotalStudents”, “87″ );

    Viewstate should be used when you want to save a value between different roundtrips of a single page as viewstate of a page is not accessible by another page.

    Because Viewstate renders with the page, it consumes bandwidth, so be careful to use it in applications to be run on low bandwidth.

    View state is stored on client side ( HTML page in hidden fields ) not on server.

    You can store view state in session by using

    <configuration>
        <system.web>
            <browserCaps>
                <case>RequiresControlStateInSession=true</case>
            </browserCaps>
        </system.web>
    </configuration>
    
    OR On page
    
    protected override PageStatePersister PageStatePersister
    {
        get
        {
            return new SessionPageStatePersister(this);
        }
    }



    Tuesday, February 5, 2013 8:18 AM
  • User88744855 posted

    thanks for ur answer but i ask a bit different question. in asp.net many server side control is available. i guess not all controls use viewstate to maintain its state during postback. i just need to know the name of those specific server side asp.net controls which use viewstate to maintain its state. can u name it?

    can u discuss on this elaborately

    <configuration>
        <system.web>
            <browserCaps>
                <case>RequiresControlStateInSession=true</case>
            </browserCaps>
        </system.web>
    </configuration>

    OR On page

    protected override PageStatePersister PageStatePersister
    {
        get
        {
            return new SessionPageStatePersister(this);
        }
    }

    Wednesday, February 6, 2013 2:03 AM
  • User-861818263 posted

    As previosly i menthioned

    Viewstate contains state of all server side controls on a page whose “EnableViewstate” property is “true”.

    Also from code provided by me you can store viewstate in session instead of on page.


    Wednesday, February 6, 2013 3:08 AM
  • User88744855 posted

    i think this is not true. say for textbox if u disable viewstate for textbox then textbox value maintain during postback but control like gridview must have enable viewstate property should be true otherwise glitches will be there for gridview output.

    Friday, February 8, 2013 1:58 AM
  • User-861818263 posted

    When you submit a form to a server, the browser always send the field values
    (those who are named, not disabled and inside the form) to the server. This
    is how a HTML form works "by design".

    The "viewstate" is just an hidden field added by ASP.NET to store extra
    informations and carry them over accross multiple server side executions of
    the same page. It doesn't contains field values.

    When you make enableviewstate=true then textbox values will be sotered in viewstate.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 8, 2013 3:44 AM