|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ajax after update - Test Page</title>
<script type="text/javascript">
function EndRequestHandler(sender, eArgs)
{
/*
1. Alert/Message if any after update
2. Error handling if any
3. Scroll position set again
4. Focus/UI update if any
*/
//Example
if (eArgs.get_error() == null)
{
// Do all the stuffs needed after update through javascript here.
//1.
//alert("Update was successful");
//2.
document.getElementById("lblTest").innerText = "Update Successful";
//3.
//Set Scroll Position
}
else
{
// There was an error in the update panels update - caught here and message displayed
document.getElementById("lblTest").innerText = "There was an error in update:"+eArgs.get_error().message;
}
}
function LoadAfterAjaxHandler()
{
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}
</script>
</head>
<body onload="LoadAfterAjaxHandler()">
<form id="form1" runat="server">
<asp:ScriptManager ID="smTest" runat="server" />
<div>
<asp:UpdatePanel ID="upTest" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtTest" runat="server"></asp:TextBox>
<asp:Button ID="btnTest" runat="server" Text="Button" OnClick="btnTest_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Label ID="lblTest" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.