scriptmanager(ASP.NET中ScriptManager控件如何使用)

发布时间: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元素:

  1. <p>

  2. <asp:ScriptManagerIDasp:ScriptManagerID="ScriptManager1"runat="server">

  3. <Services>

  4. <asp:ServiceReferencePathasp:ServiceReferencePath=
    "SimpleWebService.asmx"/>

  5. </Services>

  6. </asp:ScriptManager>

  7. <asp:contentplaceholderidasp:contentplaceholderid=
    "ContentPlaceHolder1"runat="server">

  8. </asp:contentplaceholder>

  9. &nbsp;<h4>请输入名称:</h4>

  10. <inputidinputid="inputName"type="text"/>

  11. <inputidinputid="button"type="button"value="确定"onclick=
    "returnOnbuttonGo_click()"/>

  12. </p>

添加一个Content-Page,在它上面添加一个ScriptManagerProxy控件,并引入WebService CalculWebService.asmx,并添加相应的HTML元素:

  1. <p>

  2. <asp:ScriptManagerProxyidasp:ScriptManagerProxyid=
    "ScriptManagerProxy1"runat="server">

  3. <Services>

  4. <asp:ServiceReferencePathasp:ServiceReferencePath=
    "CalculWebService.asmx"/>

  5. </Services>

  6. </asp:ScriptManagerProxy>

  7. <h4>请输入两个数:</h4>&nbsp;<inputidinputid="inputA"type=
    "text"style="width:110px"/>&nbsp;+&nbsp;

  8. <inputidinputid="inputB"style="width:110px"type="text"/>&nbsp;

  9. <inputidinputid="buttonEqual"type="button"value="="onclick=
    "returnOnbuttonEqual_click()"/>

  10. </p>

上述就是小编为大家分享的ASP.NET中ScriptManager控件如何使用了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注本站行业资讯频道。

scriptmanager
需要做网站?需要网络推广?欢迎咨询客户经理 13272073477