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? 




Related articles:

We produced by the Home should achieve four objectives
  When I began to design a Web site, usually backward production.    I began to design the station in the smallest parts: description of a story or a page of the search results page.    Then I began to design to accommodate these small part of the page: indexing pages or reg...
How to make your website in the industry come to the fore?
  If your website to come to the fore in the same industry, then your site must be a network marketing and e-commerce perfect combination, have a strong function of network marketing e-commerce sites.    More before the e-commerce site in the efforts, while neglecting the importance ...
Firework production Signed effects Logo
  FW today to talk about doing LOGO, or only look at the effects of the visual animation Lo temporary stay, although is the most simple way, it is also the most complicated, I produced a LOGO.    1. Opened image, editing choices are the size of 88 * 31 plans.    2. This LO...
§¨? ? ? §? Prosmart ? ?§
  <script LANGUAGE="javascript">    <! --    Function checkNum (str) (return! / \ D (6) /. Test (str))    Function check ()    (    If (document.form.tell.value ==""){    Alert ( "Ո ݔ...
Fireworks see from the color design software use
  Color image is the most important factor, a beautifully designed image of the people on the move is its visual effects, color selection and thus with it is essential.    Fireworks MX 2004 provides a powerful color capabilities, we can not only choose a variety of ways to use color ...