Hi guys,
i have asp.net website in c#...
i have a web user control, in which i have a timer where i'm dealing with the session time out & this timer is with interval of 1000 milliseconds.
and i have placed this timerUserCtrl on my masterpage.
but on every second the page is getting load, which is degrading the performance of the page, means, its not allowing to do anything on the page, as soon as the user want to select from list its get refresh.....
timeruserctrl
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="TimerSession" runat="server" ontick="TimerSession_Tick">
</asp:Timer>
<asp:Panel ID="PanelSession" Visible="false" runat="server">
<table class="addgrid">
<tr style="background-image: removed('images/Background.png'); height: 30px; color: Black;">
<td>
Session About Expire
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbl" runat="server"></asp:Label><br />
<center>
Your Session is about to Expire, Do you want to Continue?
</center><br /></td>
</tr>
<tr>
<td>
<div style="padding-removed 200px;">
<asp:Button ID="btnContinue" runat="server" Text="Continue" CssClass="WhiteBlackBtn"
onclick="btnContinue_Click" />
<asp:Button ID="btnCancel" runat="server" CssClass="WhiteBlackBtn" Text="Cancel"
onclick="btnCancel_Click" />
</div>
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TimerSession" />
<asp:AsyncPostBackTrigger ControlID="btnContinue" />
</Triggers>
</asp:UpdatePanel>
timeuserctrl.cs
protected void Page_Load(object sender, EventArgs e)
{
TimerSession.Enabled = true;
TimerSession.Interval = 1000;
}
protected void TimerSession_Tick(object sender, EventArgs e)
{
if (Session["timeout"] != null)
{
if (0 > DateTime.Compare(DateTime.Now, DateTime.Parse(Session["timeout"].ToString())))
{
string mins = ((Int32)DateTime.Parse(Session["timeout"].ToString()).Subtract(DateTime.Now).TotalMinutes).ToString();
if (mins == "1")
{
PanelSession.Visible = true;
TimerSession.Enabled = false;
}
}
}
else
{
Response.Redirect("logout.aspx");
}
}
Masterpage.master
<uc1:SessionTimeoutCtrl ID="SessionTimeoutCtrl1" runat="server" />
<asp:ContentPlaceHolder id="CntPLH_MainContent" runat="server">
</asp:ContentPlaceHolder>
can anyone please help me, how can i stop this page getting refresh on every second.
Thanks