ASP Net Controls ASP.Net Tutorial

<%@ Page Language="C#" AutoEventWireup="true"
   CodeFile="Default.aspx.cs" Inherits="HiddenFieldTest" %>



    HiddenField Test
    
      #left { float: left; width: 200px; }
      #right { float: right; width: 200px; }
    


   
   
      

HiddenField Test


      Click multiple times on these two images
       
                            
                                         runat="server" 
                             ImageUrl="http://www.rntsoft.com/style/logo.png" 
                             AlternateText="Click on me" 
                             OnClick="ibtnImage1_Click" />
            
         

      

      
         
                                         runat="server" 
                             ImageUrl="http://www.rntsoft.com/style/logo.png" 
                             AlternateText="Click on me" 
                             OnClick="ibtnImage2_Click" />
            
         
               
      
      
            
   
   


File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class HiddenFieldTest : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
      if (!IsPostBack)
      {
         hfImage1.Value = "0";
         hfImage2.Value = "0";
      }
   }
   protected void ibtnImage1_Click(object sender, EventArgs e)
   {
      IncrementCount(hfImage1);
      labMessage1.Text = "# Clicks: " + hfImage1.Value;
   }
   protected void ibtnImage2_Click(object sender, EventArgs e)
   {
      IncrementCount(hfImage2);
      labMessage2.Text = "# Clicks: " + hfImage2.Value;
   }
   private void IncrementCount(HiddenField hf)
   {
      int count = Convert.ToInt32(hf.Value);
      count++;
      hf.Value = count.ToString();
   }
}