ASP.NET AJAX中ScriptManager控件

在ASP.NET AJAX中,由于一个ASPX页面上只能有一个ScriptManager控件,所以在有Master-Page的情况下,如果需要在Master-Page和Content-Page中需要引入不同的脚本时,就需要在Content-page中使用ScriptManagerProxy控件,而不是ScriptManager,ScriptManagerProxy和 ScriptManager是两个非常相似的控件。ASP.NET AJAX简单定义形式如下:

 
 
 
  1. <asp:ScriptManagerProxyidasp:ScriptManagerProxyid="ScriptManagerProxy1"runat="server"> 
  2.  
  3. <asp:ServiceReferencePathasp:ServiceReferencePath="CalculWebService.asmx"/> 
  4.  
  5.  

在它下面可以添加的子标签有:Services,Scripts,AuthenticationService,ProfileService

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

 
 
 
  1.  
  2. <asp:ScriptManagerIDasp:ScriptManagerID="ScriptManager1"runat="server"> 
  3.  
  4. <asp:ServiceReferencePathasp:ServiceReferencePath=
    "SimpleWebService.asmx"/> 
  5.  
  6.  
  7. <asp:contentplaceholderidasp:contentplaceholderid=
    "ContentPlaceHolder1"runat="server"> 
  8.  
  9.  

    请输入名称:

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

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

 
 
 
  1.  
  2. <asp:ScriptManagerProxyidasp:ScriptManagerProxyid=
    "ScriptManagerProxy1"runat="server"> 
  3.  
  4. <asp:ServiceReferencePathasp:ServiceReferencePath=
    "CalculWebService.asmx"/> 
  5.  
  6.  
  7. 请输入两个数:

     <inputidinputid="inputA"type=
    "text"style="width:110px"/> +   
  8. <inputidinputid="inputB"style="width:110px"type="text"/>   
  9. <inputidinputid="buttonEqual"type="button"value="="onclick=
    "returnOnbuttonEqual_click()"/> 
 

关于ASP.NET AJAX中ScriptManagerProxy控件就介绍到这儿,有个问题就是在我的IDE中为什么ScriptManagerProxy总是提示为未知元素,但运行起来并不抱错,结果也可以出来?

【编辑推荐】

  1. 介绍ASP.NET MVC框架
  2. 浅谈ASP.NET MVC的MvcContrib.FluentHtml
  3. ASP.NET框架的功能与ASP.NET MVC模式的应用介绍
  4. 浅析Asp.net MVC生命周期
  5. 配置ASP.NET AJAX概述

网站栏目:ASP.NET AJAX中ScriptManager控件
网站URL:http://csdahua.cn/article/djoijhh.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流