in LoadViewState() : ViewState is empty ??

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 executed but ViewState["FName"] is empty --> normal
- SaveViewState() event is executed as well and saves a value in the
ViewState-object

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 ?

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

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top