Hai All,
I am using ajaxtoolkit’s modalpopupextender control to alert user about expiring session.what i need for every 5mins if the site is ideal it will show alert message your seesion is expering if u want to extend if it is ok then u have reset the time like that for that
i wrote my code like this.but dnt knw i am getting error in script its not wroking properly can any one tel me how to do this task
my .aspx page
my .cs file in page load
I am using ajaxtoolkit’s modalpopupextender control to alert user about expiring session.what i need for every 5mins if the site is ideal it will show alert message your seesion is expering if u want to extend if it is ok then u have reset the time like that for that
i wrote my code like this.but dnt knw i am getting error in script its not wroking properly can any one tel me how to do this task
<
script
type
=
"text/javascript"
>
function ShowAlert() {
$find('mpe_alert').show();
}
function hide() {
$find('mpe_alert').hide();
}
function onOk() {
$find('mpe_alert').hide();
_doPostBack($find('btnOk'), '')
}
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<%-- <
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
AsyncPostBackTimeout
=
"180"
ScriptMode
=
"Release"
EnableScriptGlobalization
=
"true"
EnablePageMethods
=
"true"
>
</
asp:ScriptManager
>--%>
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager1"
EnablePageMethods
=
"true"
/>
<
telerik:RadSkinManager
ID
=
"QsfSkinManager"
runat
=
"server"
Skin
=
"Metro"
ShowChooser
=
"false"
/>
<
asp:HiddenField
ID
=
"hdnSessionExpire"
runat
=
"server"
/>
<
cc1:ModalPopupExtender
ID
=
"mpe_alert"
runat
=
"server"
TargetControlID
=
"hdnSessionExpire"
PopupControlID
=
"pnlAlert"
CancelControlID
=
"btnCancel"
OkControlID
=
"btnOk"
BehaviorID
=
"mpe_alert"
ö
nOkScript
=
"onOk()"
>
</
cc1:ModalPopupExtender
>
<
asp:Panel
ID
=
"pnlAlert"
runat
=
"server"
Height
=
"100px"
Style
=
"display: none"
Width
=
"250px"
>
<
table
width
=
"100%"
>
<
tr
>
<
td
align
=
"left"
style
=
"font-weight: bold; font-family: Arial"
>
<
asp:Label
ID
=
"lblSessionAlert"
runat
=
"server"
Text
=
"Session Expiry Alert"
></
asp:Label
>
</
tr
>
</
table
>
<
table
>
<
tr
>
<
td
colspan
=
"2"
>
<
asp:Label
ID
=
"lblMessage"
runat
=
"server"
Font-Bold
=
"true"
Text
=
"Your session is going to expire in 1 minute. Would you like to extend your session?"
></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
br
/>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>
<
asp:Button
Text
=
"Yes"
value
=
"Yes"
runat
=
"server"
ID
=
"btnOk"
/>
</
td
>
<
td
align
=
"left"
>
<
asp:Button
Text
=
"Cancel"
value
=
"No"
runat
=
"server"
ID
=
"btnCancel"
/>
</
td
>
</
tr
>
</
table
>
</
asp:Panel
>
</
div
>
Session.Timeout = 5;
int MillisecondsTimeout = (Session.Timeout * 60000) - 120000;
string strScriptAlert = @"window.setInterval('ShowAlert()' , " + MillisecondsTimeout.ToString() + @"); ";
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", strScriptAlert, true);
int Timeout = (Session.Timeout * 60000) - 60000;
string strScriptHideAlert = @"window.setInterval('hide()' , " + Timeout.ToString() + @"); ";
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "HideAlert", strScriptHideAlert, true);
Response.AppendHeader("Refresh", Convert.ToString((Session.Timeout * 60)) + ";URL=Login.aspx");