ASP.NET AJAX entry Series (3): Controls the use of ScriptManagerProxy
Related Tags:
In ASP.NET AJAX, because of an ASPX pages there can be only one ScriptManager control, a master pages in the circumstances, if need-Master Page and Content-Page in the need to introduce a different script, this Content-on the need for the use of ScriptManagerProxy page, rather than ScriptManager, ScriptManager and ScriptManagerProxy are two very similar controls.
Main content
1. Controls outlined ScriptManagerProxy
2. Simple examples
1. Controls outlined ScriptManagerProxy
In ASP.NET AJAX, because of an ASPX pages there can be only one ScriptManager control, in a Master-Page circumstances, if need-Master Page and Content-Page in the need to introduce a different script, Content-page need to use ScriptManagerProxy rather than ScriptManager, ScriptManagerProxy and ScriptManager are two very similar controls. Simple definition of the form are as follows:
<asp:ScriptManagerProxy Id="ScriptManagerProxy1" runat="server"> 
<Services> 
<asp:ServiceReference Path="CalculWebService.asmx" /> 
</ Services> 
</ Asp: ScriptManagerProxy> Below it can be added to the sub-labels: Services, Scripts, AuthenticationService, ProfileService 2. Simple examples
Below see a simple example of the use of ScriptManagerProxy.
1. First, we prepared two WebService in the Master-Page, we enter a string, and in-Page Content, we seek and the number of two.
SimpleWebService.asmx. Add a Master-Page, in which the above add a ScriptManager control, and the introduction of WebService SimpleWebService.asmx, and add the corresponding html elements:. Add a Content-Page, in the above add a ScriptManagerProxy it controls, and the introduction of WebService CalculWebService.asmx, and add the corresponding HTML elements:
[ScriptService] 

Public class SimpleWebService: System.Web.Services.WebService
( 

Public SimpleWebService ()
( 
/ / Uncomment the following line if using designed components 
/ / InitializeComponent (); 
) 
[WebMethod] 
Public string EchoString (String s) 


(
Return "Hello" + s;
) 
) CalculWebService.asmx
[ScriptService] 

Public class CalculWebService: System.Web.Services.WebService
( 

Public CalculWebService ()
( 
/ / Uncomment the following line if using designed components 
/ / InitializeComponent (); 
) 

[WebMethod] 

Public int Add (int a, int b)
( 
Return a + b;
)
) 2
<div> 
<asp:ScriptManager ID="ScriptManager1" runat="server"> 
<Services> 
<asp:ServiceReference Path="SimpleWebService.asmx" /> 
</ Services> 
</ Asp: ScriptManager> 
<asp:contentplaceholder Id="ContentPlaceHolder1" runat="server"> 
</ Asp: contentplaceholder> 
<h3> Enter Name: </ h3> 
<input Id="inputName" type="text" /> 
<input Id="button" type="button" value=" do定" onclick="return OnbuttonGo_click()" /> 
</ Div> JS prepared by the corresponding code:

<script Type="text/javascript" language="JavaScript"> 

Function OnbuttonGo_click () 


(
SimpleWebService.EchoString requestSimpleService = ( 
Document.getElementById ( 'inputName'). Value, / / params 
OnRequestComplete / / Complete event 
); 
Return false;
) 
Function OnRequestComplete (result) 


(
Alert (result);
) 
</ Script> 3
<div> 
<asp:ScriptManagerProxy Id="ScriptManagerProxy1" runat="server"> 
<Services> 
<asp:ServiceReference Path="CalculWebService.asmx" /> 
</ Services> 
</ Asp: ScriptManagerProxy> 
Please enter <h3> two: </ h3> <input id="inputA" type="text" style="width: 110px" /> + 
<input Id="inputB" style="width: 110px" type="text" /> 
<input Id="buttonEqual" type="button" value=" = "onclick="return OnbuttonEqual_click()"/> 
</ Div> JS prepared by the corresponding code:

<script Type="text/javascript" language="JavaScript"> 

Function OnbuttonEqual_click () 

(
CalculWebService.Add requestSimpleService = ( 
Document.getElementById ( 'inputA'). Value, / / params 
Document.getElementById ( 'inputB'). Value, / / params 
OnRequestComplete / / Complete event 
); 
Return false;
) 
Function OnRequestComplete (result) 


(
Alert (result);
) 
</ Script> 4. After running the interface as follows: 
Page Master-testing in the Web Service:

Page Content-testing in the Web Service:

On the ScriptManagerProxy introduced here, there is a problem in my IDE why ScriptManagerProxy always tips for the unknown elements, but not up and running Baoxi results can come out?
- Css choice of the type, the entry of knowledge!
- WEB2.0 standards handbook: CSS seventh day of entry
- CSS primary entry: Connection Properties
- CSS primary entry: text attributes
- XML fine entry of the CSS and XSL
- Div + CSS layout entry Guide (to)
- CSS entry teaching 14 Q & A
- CSS learning from entry to the master
- DIV + CSS layout examples entry (directory)
- Div + css layout entry
- DIV + CSS page layout entry
- DIV + CSS layout and preliminary outline entry
- CSS entry
- CSS layout entry [css]
- 8 days: CSS layout entry
- 7 days: CSS entry
- DIV CSS layout and preliminary outline entry
- DIV CSS layout examples entry (directory)
- Div + CSS layout entry Guide
- CSS entry [to]




