ASP.NET中ScriptManager控件如何使用
更新:HHH   时间:2023-1-7


这期内容当中小编将会给大家带来有关ASP.NET中ScriptManager控件如何使用,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

在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. <div> 

  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. </div> 

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

  1. <div> 

  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. </div> 

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

返回编程语言教程...