To register a hidden field for a control that is inside an
UpdatePanel control so that the field is registered only when the panel is updated, use the
RegisterHiddenField(Control, String, String) overload of this method. If you are registering a hidden field that does not pertain to partial-page updates and you want to register a hidden field only one time during initial page rendering, use the
RegisterHiddenField(String, String) method of the
ClientScriptManager class.
Chetan Sarode
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
y_great2002
Member
1 Points
7 Posts
Access HiddenField when using Update Panel
Jun 06, 2007 10:42 PM|LINK
Hello,
I have a page that using update panel. I register hiddenfield using ScriptManager.Registerhiddenfield. I want to get the value, but it always failed.
This is the code :
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = this.Request.Form["__vsKey"];
}
protected void Button1_Click(object sender, EventArgs e)
{
ScriptManager.RegisterHiddenField(this, "__vsKey", "myValue");
}
When I don't use update panel, it's working properly. Do anyone know how to access the value?
Thanks before
RegisterHiddenField
chetan.sarode
All-Star
53389 Points
9034 Posts
Re: Access HiddenField when using Update Panel
Jun 07, 2007 04:38 AM|LINK
What kind of error you are getting ?
To register a hidden field for a control that is inside an UpdatePanel control so that the field is registered only when the panel is updated, use the RegisterHiddenField(Control, String, String) overload of this method. If you are registering a hidden field that does not pertain to partial-page updates and you want to register a hidden field only one time during initial page rendering, use the RegisterHiddenField(String, String) method of the ClientScriptManager class.
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
y_great2002
Member
1 Points
7 Posts
Re: Access HiddenField when using Update Panel
Jun 07, 2007 08:53 AM|LINK
The problem is I don't get the value from this hiddenfield when using UpdatePanel. It always return null value.
I'm using a button to register the hiddenfield
protected void Button1_Click(object sender, EventArgs e)
{
ScriptManager.RegisterHiddenField(this, "__vsKey", "myValue");
}
And when the page load, a label display the hiddenfield value
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = this.Request.Form["__vsKey"];
}
But, the label display nothing when I use UpdatePanel.