Monday, 30 July 2012

asp.net application state example: how to use application state in asp.net

asp.net application state example: how to use application state in asp.net


  1. <%@ Page Language="C#" %>  
  2.   
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  4.   
  5. <script runat="server">  
  6.     protected void Button1_Click(object sender, System.EventArgs e) {  
  7.         int counter = 0;  
  8.         if(Application["ButtonClickCounter"] !=null)  
  9.         {  
  10.             counter = (int)Application["ButtonClickCounter"];  
  11.         }  
  12.         counter++;  
  13.         Application["ButtonClickCounter"] = counter;  
  14.         Label1.Text = "Button Clicked: " + counter.ToString() + " times";  
  15.     }  
  16. </script>  
  17.   
  18. <html xmlns="http://www.w3.org/1999/xhtml">  
  19. <head runat="server">  
  20.     <title>asp.net application state example: how to use application state in asp.net</title>  
  21. </head>  
  22. <body>  
  23.     <form id="form1" runat="server">  
  24.     <div>  
  25.         <h2 style="color:Teal">asp.net application state example</h2>  
  26.         <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson">  
  27.         </asp:Label>  
  28.         <br /><br />  
  29.         <asp:Button   
  30.             ID="Button1"   
  31.             runat="server"   
  32.             Text="Show Button Click Status"  
  33.             OnClick="Button1_Click"  
  34.             Font-Bold="true"  
  35.             ForeColor="SeaGreen"  
  36.             />  
  37.     </div>  
  38.     </form>  
  39. </body>  
  40. </html>  

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home