Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
43
rated 0 times [  50] [ 7]  / answers: 1 / hits: 25927  / 10 Years ago, mon, june 9, 2014, 12:00:00

I create a Session[smn] when click a button.



I want Session will clear when popup control closed.



   <script type=text/javascript>

function ClearSession()
{
//clear Session[smn];
}

</script>


ASPxPopupControl



 <dx:ASPxPopupControl ID=popup1 PopupHorizontalAlign=WindowCenter  runat=server 
ClientInstanceName=popup1 PopupVerticalAlign=WindowCenter ShowPinButton=true
ShowCollapseButton=true CloseAction=CloseButton AllowDragging=True Width=800px Height=600px>
<ContentCollection>
<dx:PopupControlContentControl ID=PopupControlContentControl1 runat=server>



</dx:PopupControlContentControl>
</ContentCollection>

<ClientSideEvents CloseButtonClick=ClearSession />
</dx:ASPxPopupControl>


How can I clear Session[smn] in ClearSession() function ?


More From » asp.net

 Answers
83

if you need to clear the session on popup close in your CloseButtonClick event, then you can use a hidden button on your page and fire that event using javascript to clear your session like below:



1.Add CSS in your page




   <style>.hidden { display: none; }</style> 



2.Add this script




   function ClearSession() { document.getElementById(btnHidden).click(); }



3.Add a hidden control like this one




   <asp:Button ID=btnHidden runat=server CssClass=hidden 
OnClick=Button1_Click ClientIDMode=Static />



4.Add this one in your code behind




   protected void Button1_Click(object sender, EventArgs e) { Session[smn] = null; }



Now on your control you just need to call the javascript above, pretty much the same as yours:




   <ClientSideEvents CloseButtonClick=ClearSession() />


[#70647] Friday, June 6, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
randall

Total Points: 492
Total Questions: 99
Total Answers: 103

Location: Solomon Islands
Member since Fri, Oct 8, 2021
3 Years ago
;