The Hidden Field control is used to store a value that
needs to be persisted across posts to the server. It is rendered as an <input type=
"hidden"/> element.
Normally view state, session state, and cookies are
used to maintain the state of a Web Forms page. However, if these methods are
disabled or are not available, you can use the Hidden
Field control to store
state values.
To
specify the value for a Hidden Field control,
use the Value property. You can provide a routine
that gets called every time the value of the Hidden Field control
changes between posts to the server by creating an event handler for the Value Changed event.
Implementation of Hidden
Field:
DEMO :
HiddenField
|
|
<asp:HiddenField
ID="HiddenField1" runat="Server" Value="This is the
Value of Hidden field" />
<asp:Button
ID="Button1" runat="Server"
OnClick="ChangeLabelText" Text="Change Label Text to Hiidden
Field Value" />
// CODE BEHIND
// Fires when Button is clicked
protected void
ChangeLabelText(object sender, EventArgs e)
{
Label1.Text =
hiddeFieldValue.Value;
}
|
Advantages:
a. Easy to implement
b. Hidden fields are supported by all browsers
c. Enables faster access of information because data is stored on client side
b. Hidden fields are supported by all browsers
c. Enables faster access of information because data is stored on client side
Disadvantages:
a. Not secure because the data is stored on Client
side.
b. Decreases page performance if too many hidden fields
c. Only support single value.
b. Decreases page performance if too many hidden fields
c. Only support single value.
No comments:
Post a Comment