Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear Viewstate?

Tags:

c#

.net

asp.net

I am having a problem in which two controls which are added programmatically are trying to load each other viewstate, I want to clear the viewstate before loading the controls, I tried Viewstate.Clear but it did nothing, when I disable viewstate on the container of my controls everything works fine except that the control's state is not kept. Is there a way to clear viewstate of just a specific control?

like image 451
ryudice Avatar asked Feb 22 '10 21:02

ryudice


People also ask

Where is ViewState data stored?

By default, view state data is stored in the page in a hidden field and is encoded using base64 encoding. In addition, a hash of the view state data is created from the data by using a machine authentication code (MAC) key.

What is disable or remove ViewState hidden field in asp net page?

The only possible way to remove the ViewState Hidden Field is by removing it from the generated HTML of the Page with the help of Regular Expressions. In order to achieve the above objective, the Render event will be overridden and the ViewState Hidden Field will be removed from the generated HTML.

Which one of the following code is correct in disabling ViewState for a page in asp net?

To disable ViewState for a page To disable ViewState for a single page, set the EnableViewState attribute in the @ Page directive to false, as in the following: <%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeFile="URLRouting. aspx.


1 Answers

Yes ,

string controlName = "name of control";
ViewState[controlName] = null;
// create control, add it to the page
like image 61
cpkilekofp Avatar answered Oct 27 '22 08:10

cpkilekofp