When to enable/disable Viewstate

Error processing SSI file

Answers

  1. Gage

    • 2021/5/6

    Yes it is a very good idea. One could argue that it should have been disabled by default by Microsoft, just like caching.

    To see how bad Viewstate is in terms of size increased you can use a tool called Viewstate Analyzer. This is particularly useful when you have an existing application developed with Viewstate enabled.

    Another good reason to disable Viewstate is that it is really hard to disable at a later stage, when you have loads of components depending on it.

  2. Owen

    • 2016/11/24

    _Viewstate can unnecessarily increase the number of bytes that need to be transferred. So unless the data is going to be used the next time , 

  3. Finn

    • 2017/8/14

    One could argue that it should have been disabled by default by Microsoft, just like caching. To see how bad Viewstate is in terms of size increased you can use a tool called Viewstate Analyzer. This is particularly useful when you have an existing application developed with Viewstate enabled. Another good reason to disable Viewstate is that it is really hard to disable at a later stage, when you have loads of components depending on it.

  4. Antonio

    • 2020/5/17

    False. ViewState can be disabled for the whole Page i.e. all controls on the Page by setting the EnableViewState property to False in the @Page Directive.

  5. Nova

    • 2016/10/4

    Definately a good idea, nothing worse that a page which a developer is binding a dataGrid in the Page_Load every time but also submitting the viewstate!

    It's also a really good idea if you are planning on using the UpdatePanel from the AJAX Extensions, it means you're submitting less during the UpdatePanel request.

    (Don't flame for saying that an UpdatePanel can be good :P)

  6. Fisher

    • 2015/10/29

    Disabling/enabling viewstate to a specific control can be done using “enable viewstaate property” Controls->properties->enable viewstate-true[default]/ false . True->control state will be maintained within hiddenfield . False->control state will not be maintained . Note: By default viewstate is disabled to password type textbox for security reason

  7. Gunnar

    • 2016/3/18

    . ViewState can be enabled and disabled in any of the following ways: Control Level. Page Level.

  8. Gunnar

    • 2019/4/6

    Then enable ViewState for the controls that you would like to enable ViewState for. Alternatively, a middle ground and less forceful way may possible if controls are groups inside other container controls (such as Panel). You can disable ViewState for all controls inside a Panel by disabling ViewState of the Panel.

  9. Jason

    • 2021/4/23

    You may find the information contained in the "ASP.NET State Management Recommendations" article on MSDN useful for making your decision.

    Generally in ASP.NET 2.0 and above disabling the ViewState is less destructive due to the introduction of the Control State for storing informaton required for raising events etc.

  10. Lennox

    • 2017/1/11

    ViewState can be disabled for the whole Page i.e. all controls on the Page by setting the EnableViewState property to False in the @Page 

  11. Braydon

    • 2020/2/24

    By default, ViewState is enabled for all server controls. ViewState can be enabled and disabled in any of the following ways: Control Level ; Page Level ; Application Level ; Machine Level ; To disable ViewState. To disable ViewState for a single control on a page, set the EnableViewState property of the control to false, as in the following:

  12. Gabriel

    • 2019/7/29

    To disable ViewState for a specific application, use the following element in the Web.config file of the application: <configuration>; <system.

  13. Marcellus

    • 2015/3/24

    I think it's good practice. Many ASP.NET devs are unaware that their viewstates add tremendous baggage to the HTML that's being sent to their users' browsers.

  14. Rinaldi

    • 2015/5/27

    On Datalist and DropDownList – If you are not using the OnSelectedIndex Change event then you may disable the viewstate. On Gridviews – This is the hardest part to decide whether to disable viewstate or retain it. If you are just displaying data on it or even using it just for selection, then disable the viewstate.

  15. Caspian

    • 2016/5/19

    For your specific questions, yes leave the viewstate enabled for searching because it requires a postback to retrieve data and for paging. When 

  16. Jamir

    • 2020/5/15

    Sub Page_Load(sender As Object, e As System.EventArgs) DataBind() ' Set EnableViewState to false to disable saving of view state ' information. myControl.EnableViewState = False If Not IsPostBack Then display.Enabled = False End If End Sub Remarks. View state enables a server control to maintain its state across HTTP requests.

  17. Eden

    • 2018/11/23

    It's a good practice. Unless you use ViewState values on postbacks, or they are required by some complex control itself it's good idea to save on ViewState as part of what will be sent to the client.

  18. Pablo

    • 2017/1/15

    1. Page Level: To enable or disable ViewState in the Page Level, use the following in the Page directive of the ASP.NET page.

  19. Hunter

    • 2020/10/13

    Quote: Why some controls retain values even after disabling the ViewState while others do not? The answer is Controls which implements 

  20. Javion

    • 2019/11/17

    Here's what Pooja Daga writes about your question? You can disable a control's view state if the control does not contain any dynamic data, its 

  21. Vicente

    • 2016/3/14

    By default, ViewState is enabled for all server controls. To enable or disable ViewState in the Page Level, use the following in the 

Comments are closed.

More Posts