KaranGupta
asked on
base.LoadViewState
Hi
What is the purpose of this and is there any scenario where I can use it
What is the purpose of this and is there any scenario where I can use it
ASKER
Is base.LoadViewState and Control.LoadViewState same
The base keyword is used to access members of the base class from within a derived class:
Call a method on the base class that has been overridden by another method.
Specify which base-class constructor should be called when creating instances of the derived class.
A base class access is permitted only in a constructor, an instance method, or an instance property accessor.
It is an error to use the base keyword from within a static method.
Source: http://msdn.microsoft.com/en-us/library/hfw7t1ce(v=vs.71).aspx
Call a method on the base class that has been overridden by another method.
Specify which base-class constructor should be called when creating instances of the derived class.
A base class access is permitted only in a constructor, an instance method, or an instance property accessor.
It is an error to use the base keyword from within a static method.
Source: http://msdn.microsoft.com/en-us/library/hfw7t1ce(v=vs.71).aspx
ASKER
Hi
I have created 2 pages one is source_view_state.aspx and destination_view_state.asp x on the source_view_state. aspx file there is a textbox and a button. On Click of button I have written the following code
Now on the destination_view_state.asp x I have written the following code
which I guess is the method in page life cycle for loading viewstate. This event is not fired. Do we need to call that event explicitly
I have created 2 pages one is source_view_state.aspx and destination_view_state.asp
ViewState["K"] = TextBox1.Text;
base.SaveViewState();
Response.Redirect("Destination_View_State.aspx");
Now on the destination_view_state.asp
protected override void LoadViewState(object savedState)
{
object[] states = (object[])savedState;
}
which I guess is the method in page life cycle for loading viewstate. This event is not fired. Do we need to call that event explicitly
Textbox1 value is already in viewstate and why you want to create another viewstate ViewState["K"] ?
Use server.transfer to go to next page and user Form["<ID>"] to get the values from the soruce page.
Use server.transfer to go to next page and user Form["<ID>"] to get the values from the soruce page.
ASKER
Hi apeter
I was just trying to find out the practical usage of LoadViewState. Could you please help me out?
Regards
Karan Gupta
I was just trying to find out the practical usage of LoadViewState. Could you please help me out?
Regards
Karan Gupta
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Restores view-state information from a previous page request that was saved by the SaveViewState method.
http://msdn.microsoft.com/en-us/library/system.web.ui.control.loadviewstate(v=vs.85).aspx