PageLoad event in ASP.NET AJAX using ScriptManager

This entry is part 6 of 13 in the series ASP.NET Ajax

Create an ASP.NET page and write following code in aspx page (overwrite existing code). Run your page.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Client Side Event in ASP.NET Ajax</title>
<script language="javascript" type="text/javascript">
function pageLoad() {
alert("Page load fires");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server" ID="SM1" />
</div>
</form>
</body>
</html>

You will notice that you will get an alert message “Page load fires” as soon as page loads.
Now try to remove the ScriptManager and run the page, notice that you will not get the alert.
Here the pageLoad event fires because of the client side framework that comes out of ASP.NET AJAX in ScriptManager.

Series Navigation«ASP.NET AJAX Server ExtensionArray extensions in ASP.NET AJAX client side framework»

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.