Search content within the blog

Thursday, November 13, 2008

Calling serverside code when closing browser

ASPX.CS Contents

protected void Page_Load(object sender, EventArgs e)
if (Request.Form["__EVENTTARGET"] == "FromJavascript")

public void MyFuntion()
Response.Write("test write from server");

ASPX Contents

<html xmlns="" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script language="javascript">
function PerformServerTasks()
alert("Form Unloading. After you click ok to this message.Server Side code will work");
<body onunload="PerformServerTasks();">
<form id="form1" runat="server">
<h1>Test Page</h1>
<%-- <a href="#" onclick="PerformServerTasks();">s</a>--%>
<input id="Text1" type="text" runat="server" value="" />
<asp:TextBox ID="SDF" runat="server" AutoPostBack="True" Text="Dont worry about this textbox.But dont remove it"></asp:TextBox>

No comments:

Post a Comment