hiddenfield control example

hiddenfield control example

Previous Home Next

 

HiddenField is used to create a hidden field in the form. When it is rendered on the page, it is implemented through  HTML tag. The HiddenField control is used to store a value that needs to be persisted across posts to the server.

  
     

     

  .............Desigining code for hiddenfield....................
.................................................................

.................................................................
....................Design code for lable.......................
  
..................................................................
..............cs code for button clic..........................
....................................................................
  protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
   Label1.Text = string.Format("Clicked {0} times", HiddenField1.Value);

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        HiddenField1.Value = (Convert.ToInt32(HiddenField1.Value) + 1).ToString();
        Label1.Text = string.Format("Clicked {0} times", HiddenField1.Value);}
  
Previous Home Next