viewstate??

M

Mikael Janers

Hello!

Does anyone have any information about how a
System.Web.UI.WebControls.TextBox keeps its value between posts ?
Everywhere I read it says it's the viewstate. But clearly it isn't because
if you override the controls viewstate functions and even disable viewstate
on the page the control still keep its value on a postback??

// Mikael
 
R

Ruslan

Mikael Janers said:
Hello!

Does anyone have any information about how a
System.Web.UI.WebControls.TextBox keeps its value between posts ?
Everywhere I read it says it's the viewstate. But clearly it isn't because
if you override the controls viewstate functions and even disable viewstate
on the page the control still keep its value on a postback??

// Mikael

If TextBox has Visible = False, it keeps it's value in the viewstate,
otherwise it loads the text from the postback data.

The execution flow is somewhat like this:

Page.ProcessRequestMain() -> Page.ProcessPostData() ->
IPostBackEventHandler(control).LoadPostData() ->
Control.LoadPostData()

The actual implementation for the TextBox is here:

private bool System.Web.UI.IPostBackDataHandler.LoadPostData(string
postDataKey, NameValueCollection postCollection)
{
if (!this.Text.Equals(postCollection[postDataKey]))
{
this.Text = postCollection[postDataKey];
return true;
}
return false;
}
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top