发布时间:2025-12-11 00:42:46 浏览次数:1
在ASP.NET AJAX中,由于一个ASPX页面上只能有一个ScriptManager控件,所以在有Master-Page的情况下,如果需要在Master-Page和Content-Page中需要引入不同的脚本时,就需要在Content-page中使用ScriptManagerProxy控件,而不是ScriptManager,ScriptManagerProxy和 ScriptManager是两个非常相似的控件。ASP.NET AJAX简单定义形式如下:
<asp:ScriptManagerProxyidasp:ScriptManagerProxyid="ScriptManagerProxy1"runat="server"><Services><asp:ServiceReferencePathasp:ServiceReferencePath="CalculWebService.asmx"/></Services></asp:ScriptManagerProxy>
在它下面可以添加的子标签有:Services,Scripts,AuthenticationService,ProfileService
添加一个Master-Page,在它上面添加一个ScriptManager控件,并引入WebService SimpleWebService.asmx,并添加相应的HTML元素:
<p>
<asp:ScriptManagerIDasp:ScriptManagerID="ScriptManager1"runat="server">
<Services>
<asp:ServiceReferencePathasp:ServiceReferencePath=
"SimpleWebService.asmx"/></Services>
</asp:ScriptManager>
<asp:contentplaceholderidasp:contentplaceholderid=
"ContentPlaceHolder1"runat="server"></asp:contentplaceholder>
<h4>请输入名称:</h4>
<inputidinputid="inputName"type="text"/>
<inputidinputid="button"type="button"value="确定"onclick=
"returnOnbuttonGo_click()"/></p>
添加一个Content-Page,在它上面添加一个ScriptManagerProxy控件,并引入WebService CalculWebService.asmx,并添加相应的HTML元素:
<p>
<asp:ScriptManagerProxyidasp:ScriptManagerProxyid=
"ScriptManagerProxy1"runat="server"><Services>
<asp:ServiceReferencePathasp:ServiceReferencePath=
"CalculWebService.asmx"/></Services>
</asp:ScriptManagerProxy>
<h4>请输入两个数:</h4> <inputidinputid="inputA"type=
"text"style="width:110px"/> + <inputidinputid="inputB"style="width:110px"type="text"/>
<inputidinputid="buttonEqual"type="button"value="="onclick=
"returnOnbuttonEqual_click()"/></p>
上述就是小编为大家分享的ASP.NET中ScriptManager控件如何使用了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注本站行业资讯频道。