AJAX Package ScriptManagerProxy Control In ASP.NET Using VB.NET
In this article you learned that how can you use the ScriptManagerProxy control.
Introduction
ScriptManagerProxy control enables a user to add scripts and services that are specific to nested components. If a page already contains the ScriptManager control. Only one instance of the ScriptManager control can be added to a page. The page can include the control directly or indirectly inside a nested component such as a user control or nested master page. The ScriptManagerProxy control is used when the ScriptManager control is already in the page and a nested or parent component requires additional features of the ScriptManager control.
Getting Started
- Simply create a new ASP.NET web application.
- Drag a ScriptManagerProxy, ScriptManager and a button control on page. The page will look like below.
- Than Right click on project in solution explorer than add new item and add Web service template. Name it SimpleService.asmx as we used in the example.
- Then attach the below code.
<%@ Page Title="Home Page" Language="vb" AutoEventWireup="false"
CodeBehind="Default.aspx.vb" Inherits="ScriptManagerProxy1._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 id="Head1" runat="server">
<title>How to Use ScriptManagerProxy</title>
</head>
<script language="javascript" type="text/javascript">
<!--
function Button1_onclick() {
reqviaprovy = SimpleService.SayHello(
document.getElementById('Text1').value,
OnComplete,
OnTimeout);
return false;
}
function OnComplete(results) {
alert(results);
}
function OnTimeout(results) {
alert("Timout");
}
// -->
</script>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel runat="server" id="UpdatePanel1">
<ContentTemplate>
<asp:ScriptManagerProxy id="ScriptManagerProxy1" runat="server">
<Services>
<asp:ServiceReference Path ="SimpleService.asmx" />
</Services>
</asp:ScriptManagerProxy>
<br />
<input id="Text1" type="text" />
<input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
- Now run your application.
Output:-
Summary
In this article you learned about the AJAX package ScriptManagerProxy control.