Wednesday, 16 April 2014

Use of Post Back in ASP.NET


Create a Web Site to show the Post Back property of Web pages.

********HTML Code***************
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head runat="server">
  3.     <title></title>
  4. </head>
  5. <body>
  6.     <form id="form1" runat="server">
  7.     <div style="margin-left:20px;">
  8.     
  9.         <br />
  10.         <asp:Label ID="Label1" runat="server" Text="Click Here" ForeColor="#003300"></asp:Label>
  11.         <br />
  12.         <br />
  13.         <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
  14.     
  15.     </div>
  16.     </form>
  17. </body>
  18. </html>



********HTML Code***************
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;

  7. public partial class Post_Back : System.Web.UI.Page
  8. {
  9.     protected void Page_Load(object sender, EventArgs e)
  10.     {
  11.         if (!Page.IsPostBack)
  12.         {
  13.             Label1.Text = "Page is not in Post back";
  14.         }
  15.     }
  16.     protected void Button1_Click(object sender, EventArgs e)
  17.     {
  18.         Label1.Text = "Page is in post back";
  19.     }
  20. }

No comments:

Post a Comment