Click here to Skip to main content
16,011,923 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionRowCommand event issue in GridView Pin
trilokharry4-Sep-08 22:01
trilokharry4-Sep-08 22:01 
AnswerRe: RowCommand event issue in GridView Pin
Blue_Boy4-Sep-08 22:44
Blue_Boy4-Sep-08 22:44 
QuestionRowEditing in gridview Pin
trilokharry4-Sep-08 21:58
trilokharry4-Sep-08 21:58 
AnswerRe: RowEditing in gridview Pin
Blue_Boy4-Sep-08 22:48
Blue_Boy4-Sep-08 22:48 
GeneralRe: RowEditing in gridview Pin
trilokharry4-Sep-08 23:04
trilokharry4-Sep-08 23:04 
GeneralRe: RowEditing in gridview Pin
K V Sekhar4-Sep-08 23:07
K V Sekhar4-Sep-08 23:07 
GeneralRe: RowEditing in gridview Pin
trilokharry4-Sep-08 23:16
trilokharry4-Sep-08 23:16 
QuestionHandling browser Close (X) button Pin
K V Sekhar4-Sep-08 21:01
K V Sekhar4-Sep-08 21:01 
Hi all,

I have master page. In that i placed a LinkButton(Log Out).
If user clicks on this logout button, i am entering the login & logout information into database and i am deleting temporary folders.

Probem : When user closes Browser window by Closebutton(X), i need to enter the logout information into database & i need to delete temporary folders and files.

I tried the following logic which is suggested by Abhijit Jana.
But its not working.

if any where i went wrong, let me know.

Here is my code
MastrPage:
==========
Default.master(Design)
<%@ Master Language="C#" CodeFile="Default.master.cs" Inherits="Default_master" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script type= "text/javascript">
function UpdateDataBase()
{
// Check Browser Close [X] , Alt+F4 , File -> Close
if (window.event.clientX < 0 && window.event.clientY < 0)
{
window.open("DummyPage.aspx?test=test", "OpenWindow_Close_Session", 'left=12000,top=1200,width=10,height=1');
}
}

</script>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head runat="server">
<title></title>
</head>
<body>

<form id="form1" runat="server">

<div class="header">
<h1 style="color: #FFFFFF">Prospecta technologies</h1>
<h2 style="color: #FFFFFF">Proxy Ads Management System</h2>
<div class="nav">
<asp:Label ID="lbl_Welcome" runat="server" Visible="False" Font-Bold="True"
ForeColor="White"></asp:Label>
| &nbsp;
<asp:SiteMapPath id="SiteMapPath1" runat="Server" PathSeparator=" > " RenderCurrentNodeAsLink="true" />
&nbsp; | &nbsp;
<asp:LinkButton ID="hlink_Logout" runat="server"
onclick="hlink_Logout_Click" CausesValidation="False"
ValidationGroup="Click here for Logout" Visible="False">Logout</asp:LinkButton>
</div>
<asp:Menu id="menua" runat="server"
cssclass="menua"
orientation="Horizontal"
maximumdynamicdisplaylevels="0"
skiplinktext=""
staticdisplaylevels="2" >
<Items>
<asp:MenuItem NavigateUrl="~/LoginPage.aspx" Text="Login" Value="Login"
ToolTip="Login">
</asp:MenuItem>

<asp:MenuItem Text="About Us" ToolTip="About Us" Value=" About Us"
NavigateUrl="~/AboutUs.aspx">
</asp:MenuItem>
<asp:MenuItem NavigateUrl="~/ContactUs.aspx" Text="Contact Us"
Value="Contact Us" ToolTip="Contact Us"></asp:MenuItem>
</Items>
</asp:Menu>


</div>

<asp:contentplaceholder id="Main" runat="server" onunload="Main_Unload" />
<div class="footerbg">
<div class="footer">
<asp:Menu id="menub" runat="server"
cssclass="menub"
orientation="Horizontal"
maximumdynamicdisplaylevels="0"
skiplinktext=""
staticdisplaylevels="2" Height="16px" Width="290px" >
<Items>
<asp:MenuItem NavigateUrl="~/LoginPage.aspx" Text="Login" ToolTip="Home"
Value="Home"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/AboutUs.aspx" Text="About Us" ToolTip="About Us"
Value="About Us"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/ContactUs.aspx" Text="Contact Us"
ToolTip="Contact Us" Value="Contact Us"></asp:MenuItem>
</Items>
</asp:Menu>
</div>
</form>

</body>
</html>

My CodeBlock
Default.master.cs:(The below method is not executing when i closes the browser. I tried by placing break point)
==================
protected void Main_Unload(object sender, EventArgs e)
{
string str = "<script language='javascript'>";
str += "UpdateDataBase();";
str += "</script>";

Page.RegisterStartupScript("test", str);
}
//////////////////////////////
DummyPage.aspx.cs(This is the page i am redirecting to user from javasript method)

PageLoad()
{
if(!Page.IsPostBack)
{
if(Request.QueryString["test"]!="") // I am trying to create a direcory for Checking purpose
{
DirecoryInfo dir = new DirecoryInfo(@"D:\Test");
if(dir.Exists == false)
dir.Create();
}
}
}

..................

Please suggest me where i went wrong.

Thnks in advance.
AnswerRe: Handling browser Close (X) button Pin
Abhijit Jana4-Sep-08 21:37
professionalAbhijit Jana4-Sep-08 21:37 
GeneralRe: Handling browser Close (X) button Pin
K V Sekhar4-Sep-08 22:37
K V Sekhar4-Sep-08 22:37 
GeneralRe: Handling browser Close (X) button Pin
K V Sekhar4-Sep-08 23:13
K V Sekhar4-Sep-08 23:13 
GeneralRe: Handling browser Close (X) button Pin
Abhijit Jana4-Sep-08 23:30
professionalAbhijit Jana4-Sep-08 23:30 
GeneralRe: Handling browser Close (X) button Pin
K V Sekhar4-Sep-08 23:44
K V Sekhar4-Sep-08 23:44 
GeneralRe: Handling browser Close (X) button Pin
K V Sekhar5-Sep-08 1:01
K V Sekhar5-Sep-08 1:01 
GeneralRe: Handling browser Close (X) button Pin
Abhijit Jana5-Sep-08 1:21
professionalAbhijit Jana5-Sep-08 1:21 
GeneralRe: Handling browser Close (X) button Pin
K V Sekhar5-Sep-08 2:34
K V Sekhar5-Sep-08 2:34 
GeneralRe: Handling browser Close (X) button Pin
Abhijit Jana5-Sep-08 3:46
professionalAbhijit Jana5-Sep-08 3:46 
GeneralRe: Handling browser Close (X) button Pin
K V Sekhar5-Sep-08 18:43
K V Sekhar5-Sep-08 18:43 
GeneralRe: Handling browser Close (X) button Pin
K V Sekhar5-Sep-08 20:03
K V Sekhar5-Sep-08 20:03 
QuestionHandling browser &lt;- button Pin
K V Sekhar4-Sep-08 20:51
K V Sekhar4-Sep-08 20:51 
AnswerRe: Handling browser &lt;- button Pin
Blue_Boy4-Sep-08 21:00
Blue_Boy4-Sep-08 21:00 
GeneralRe: Handling browser &lt;- button [modified] Pin
K V Sekhar4-Sep-08 21:11
K V Sekhar4-Sep-08 21:11 
QuestionException Pin
trilokharry4-Sep-08 20:31
trilokharry4-Sep-08 20:31 
AnswerRe: Exception Pin
Blue_Boy4-Sep-08 20:41
Blue_Boy4-Sep-08 20:41 
QuestionHttp Response and Javascript Problem Pin
goradaranaresh4-Sep-08 20:30
goradaranaresh4-Sep-08 20:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.