新聞中心
在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">
- <asp:ServiceReferencePathasp:ServiceReferencePath="CalculWebService.asmx"/>
在它下面可以添加的子標簽有:Services,Scripts,AuthenticationService,ProfileService
添加一個Master-Page,在它上面添加一個ScriptManager控件,并引入WebService SimpleWebService.asmx,并添加相應(yīng)的HTML元素:
- <asp:ScriptManagerIDasp:ScriptManagerID="ScriptManager1"runat="server">
- <asp:ServiceReferencePathasp:ServiceReferencePath=
"SimpleWebService.asmx"/>- <asp:contentplaceholderidasp:contentplaceholderid=
"ContentPlaceHolder1"runat="server">- 請輸入名稱:
- <inputidinputid="inputName"type="text"/>
- <inputidinputid="button"type="button"value="確定"onclick=
"returnOnbuttonGo_click()"/>
添加一個Content-Page,在它上面添加一個ScriptManagerProxy控件,并引入WebService CalculWebService.asmx,并添加相應(yīng)的HTML元素:
- <asp:ScriptManagerProxyidasp:ScriptManagerProxyid=
"ScriptManagerProxy1"runat="server">- <asp:ServiceReferencePathasp:ServiceReferencePath=
"CalculWebService.asmx"/>- 請輸入兩個數(shù): <inputidinputid="inputA"type=
"text"style="width:110px"/> +- <inputidinputid="inputB"style="width:110px"type="text"/>
- <inputidinputid="buttonEqual"type="button"value="="onclick=
"returnOnbuttonEqual_click()"/>
關(guān)于ASP.NET AJAX中ScriptManagerProxy控件就介紹到這兒,有個問題就是在我的IDE中為什么ScriptManagerProxy總是提示為未知元素,但運行起來并不抱錯,結(jié)果也可以出來?
【編輯推薦】
- 介紹ASP.NET MVC框架
- 淺談ASP.NET MVC的MvcContrib.FluentHtml
- ASP.NET框架的功能與ASP.NET MVC模式的應(yīng)用介紹
- 淺析Asp.net MVC生命周期
- 配置ASP.NET AJAX概述
網(wǎng)站欄目:ASP.NET AJAX中ScriptManager控件
轉(zhuǎn)載來源:http://www.5511xx.com/article/djoijhh.html


咨詢
建站咨詢
