AJAX.NET users guide (2)

Related Tags:

  / / C # 

  Public class Index: System.Web.UI.Page ( 
  Private void Page_Load (object sender, EventArgs e) ( 
  Ajax.Utility.RegisterTypeForAjax (typeof (Index)); 
//...
  ) 
//...
  ) 
  RegisterTypeForAjax method call on the pages generated in the following javascript code (an alternative, you can add a page of the following javascript code) 

  <script Language="javascript" src="ajax/common.ashx"> </ script> 
  <Script language = "javascript" 
  Src = "ajax / NAMESPACE.PAGECLASS, ASSEMBLYNAME. Ashx"> </ script> 
  The code above the bold part NAMESPACE.PAGECLASS, ASSEMBLYNAME following meanings: 


NAMESPACE.PAGECLASS

  Current page space and the naming of 

ASSEMBLYNAME

  Current page the names of the procedures set 

  Below are the projects in AjaxPlay sample.aspx example output: 

  <% @ Page Inherits = "AjaxPlay.Sample" Codebehind = "sample.aspx.cs" ...%> 
  <html> 
  <head> 
  <script Language="javascript" src="ajax/common.ashx"> </ script> 
  <Script language = "javascript" 
  Src = "ajax / AjaxPlay.Sample, AjaxPlay. Ashx"> </ script> 

  </ Head> 
  <body> 
  <form Id="Form1" method="post" runat="server"> 
...
  </ Form> 
  </ Body> 
  </ Html> 
  You can test, artificial browser will src path (through the Show source files and copy) Open, it all work.    If the output so far meaningless text that is correct, if the output asp.net wrong, it will be in the middle of the error. 

  HttpHandle even if you do not understand the ways of work, should be able to understand the above description.    Web.config passed, we can ensure sent to the ajax / *. ashx the request by our custom to handle processing, it is Clear that the two scripts marked by the custom handle processing. 

  Function-preparation services 

  Now we are preparing the server-side function, they can be asynchronous client calls.    Although we can not support the return of all types, we insist on the server-side additions.    In the codebehind pages of documents, add the following methods: 

'VB.Net

  <Ajax.AjaxMethod()> _ 

  Public Function ServerSideAdd (byval firstNumber As Integer, byval secondNumber 
  As Integer) As Integer 
  Return firstNumber + secondNumber 
  End Function 

  / / C # 

  [Ajax.AjaxMethod ()] 

  Public int ServerSideAdd (int firstNumber, int secondNumber) 
  ( 
  SecondNumber return firstNumber +; 
  ) 
  Note that this function is Ajax.AjaxMethod () custom attributes, attributes services will inform the ajax Packaging category for this approach to create a javascript agents, so the client can be called. 

  Customized client calls 

  Followed by javascript client function call.    Ajax will create a package of javascript function, with two parameters, the name is the class name. ServerSideAdd.    As the most Basic function, we need to call this method only and transmission parameters: 

  <% @ Page Inherits = "AjaxPlay.Sample" Codebehind = "sample.aspx.cs" ...%> 
  <html> 
  <head> 
  <script Language="javascript" src="ajax/common.ashx"> </ script> 
  <Script language = "javascript" 
  Src = "ajax / AjaxPlay.Sample, AjaxPlay.ashx"> </ script> 

  </ Head> 

  <body> 
  <form Id="Form1" method="post" runat="server"> 
  <script Language="javascript"> 
  Var response = Sample.ServerSideAdd (100,99); 
  Alert (response.value); 
  </ Script> 
  </ Form> 
  </ Body> 
  </ Html> 


Related articles:

FLASH FLASH Avatar part Source Code Analysis
  There are several original predecessors have posted some of the code on this technology, JAVA, and some of the FLASH COM.    I now part of the FLASH images obtained through Niexiangtou paste information from the code.    For your reference.    This code is, I m...
Custom css
  Body (    Font-size: 0.9em;    Font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;    Margin-left: 10px;    Margin-right: 10px;    Background-color: # F3F5F7;    )    A: visited,    A: active,&nbs...
Flash Learning: Accordion examples of the use of components
  Production process using Flash MX Professional 2004 Chinese version, the following is the result of production plans:  <embed src=http://www.webjx.com/upfiles/20051208/20051208082214_2005127231039447.swf pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Ve...
HTML paragraphs primary Guide
  Now your HTML documents have a basic framework, you can come to "Hugao" while other elements:)    Return to the notebook, in accordance with the following new line:    Example Source Code [CSS tutorial] <DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 ...
Alexa ranks and search engine summary of the conventional problems
  Alexa site narrowing of the plan is how to achieve -----------------    Alexa statistical portrait for free:    Http://www.alexa.com/site/site_stats/signup    Update ALEXA thumbnail:    Http://thumbnails.alexa.com/update_thumbnail    ALEX...