Thursday, July 21, 2011

How to Refresh a Page conditionally in Asp.NET


When using HTML we can use  <meta> tag to  continuously Refresh a page afer a  time Interval.
<meta http-equiv="refresh" content="5"/>
Here 5 indicates Seonds after which the Page will get Refreshed.
We can use this tag in Asp.NET to Refresh our Page conditionally.
Only we have to add two more  attributes
       1.  ID
       2.  runat="server"
by which we can access this tag's content from Code behind File.
Content of .aspx File

<head runat="server">
    <meta id="refreshRate" runat="server" http-equiv="refresh" content=""/>
    <form id="form1" runat="server">
        <asp:Label ID="lblName" runat="server" Text="Devi" /> <br />
        <asp:Button ID="btnFullName" runat="server" Text="FullName" onclick="btnFullName_Click" />
Button Click Event

protected void btnFullName_Click(object sender, EventArgs e)
    lblName.Text = "Devi Prasad Das";
    btnFullName.Visible = false;
    refreshRate.Content = "2";


Post a Comment


Web Design Company karimnagar, Web Designing warangal, Logo Design Company nizamabad, Indian Website Design Company,