Asp.net ajax program design notebook 3 - ScriptManager attributes of EnablePageMethods

Related Tags:

  ScriptManager the EnablePageMethods attribute set javascript direct client services-called static WebMethod 

  EnablePageMethods.aspx 

  <script Type="text/javascript"> 
  Var txtName; 
  Var lblMsg; 
  Function pageLoad () ( 
  TxtName = new Sys.Preview.UI.TextBox ($ get ( 'txtName')); 
  LblMsg = new Sys.Preview.UI.Label ($ get ( 'lblMsg')); 
  ) 
  Function sayHello () ( 
  PageMethods.SayHello (txtName.get_text (), cb_SayHello); 
  ) 
  Function cb_SayHello (result) ( 
  LblMsg.set_text (result); 
  ) 
  </ Script> 

  <form Id="form1" runat="server"> 
<div>
  <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True"> 
<Scripts>
  <asp:ScriptReference Name="PreviewScript.js" Assembly="Microsoft.Web.Preview" /> 
  </ Scripts> 
  </ Asp: ScriptManager> 
  <input Type="text" id="txtName" /> 
  <input Type="button" value="invoke" onclick="sayHello()" /> 
  <div Id="lblMsg"> </ div> 
  </ Div> 
  </ Form> 

  EnablePageMethods.aspx.cs 

  [System.Web.Services.WebMethod] 
  Public static String SayHello (string name) 
  ( 
  Return "welcome to site" + name; 
  ) 




Related articles:

JavaScript objects and features an array reference 2
  Links array documents link an array of objects, they appear in the document in accordance with the chronological order (the attribute itself is a target)    Documents show that the current location of the URL.    Users can not change document.location (because this is the...
Pure CSS support the pull-down menu IE6
   <DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">      <html>      <! - Www.div-css.com website standardized 2007-4-16 -> ...
Flash MX 2004 produced video tutorial examples: Dreams in space (1)
  Article 22: Dreams in space (1)    Curriculum objectives: a production of "Dreams of outer space" animated screensavers    Curriculum points: The meeting between the animation, Zhou Zheng animation, ActionScript scripting technologies such as the production of...
Site model analysis: Network pick in the end we have to bring any more
  Knowledge management has always been a fine tradition of the dream of the knowledge society, but also remember childhood teachers often teach us cutting of newspapers and magazines, collecting all kinds of fine articles, or handmade, extracts information on the various types of small cards, ...
Javascript output with automatic text website
  Some people in the website frequently used text output Swish do the typing results, in fact, as JavaScript can make the effect by the following methods in HTML documents can be added JavaScript code.    Step 1: Join the following code in the region <head>    <S...