1.

What is Hidden Field & how it is implemented?

Answer»

Hidden field is a control given by ASP.NET which is UTILIZED to store limited quantities of information on the client. It stores one value for a variable and it is an ideal way when the value of that variable is changing regularly. Hidden field control isn't rendered to the browser and is invisible too. A hidden field goes with each request LIKE a standard control's worth.

Let’s see an example of how to USE this hidden field. This would INCREASE the value by 1 on EVERY button click.

The source of the hidden field control is:

<asp:HiddenField ID="HiddenField1" runat="server"  /> 

In the code-behind page:

Protected void Page_Load(object sender, EventArgs e) {    if (HiddenField1.Value != NULL)    { int val = Convert.ToInt32(HiddenField1.Value) + 1;     HiddenField1.Value = val.ToString(); Label.Text = val.ToString();    } } protected void Button1_Click(object sender, EventArgs e) {   //No Action Button Click }


Discussion

No Comment Found