in LoadViewState() : ViewState is empty after page reloads the 2nd time

C

Christian

Hi,

I have a Webform with 1 submit button and 1 label

code behind :
public class MainWebForm: System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblFName;

protected override void LoadViewState( object o )
{
lblFName.Text = (string)ViewState["FName"];
}

protected override object SaveViewState()
{
ViewState["FName"] = "Enter First Name Here";
return base.SaveViewState();
}
}

Upon loading the page the first time
- LoadViewState() is not executed yet : OK
- SaveViewState() event is executed and saves a value in
the ViewState-object :OK

Page is now displayed with an empty label : OK

Upon pressing the Submit button : page loads a second time
- LoadViewState() is executed and ViewState["FName"] is still empty ????

Why ?

Thanks

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top