Net equivalent to Ajax effect icallbackeventhandler

Source: Internet
Author: User

For more in-depth reference and research, you can refer to the following
Http://msdn2.microsoft.com/zh-cn/library/ms178210%28vs.80%29.aspx http://tech.sina.com.cn/s/2006-04-20/1522911788.shtml http://tech.sina.com.cn/s/2006-04-20/1522911789.shtml

First, it is built on the web page. Open vs2005 or later and create a website

Reprinted please specify http://netsos.cnblogs.com/

1. Drag and Drop a static control, button, and callback <button onclick = "Callback ();"> test the Ajax effect </button>

Reprinted please indicate the source of [http://netsos.cnblogs.com]

2. Write the callback function in JavaScript on the page.

Code executed in Javascript

1 < Script Type = " Text/JavaScript " >
2 // Onclick event started!
3 Function Callback ()
4 {
5 // ARGs is a variable that will be used for asynchronous processing.
6 VaR ARGs = " On the website, you need to perform Ajax and asynchronous variables, and finally input them to the background for receiving and processing. " ;
7 // The args variable is used now. receivedata is returned to the client, that is, the user's result.
8 <% = Clientscript. getcallbackeventreference ( This , " ARGs " , " Receivedata " , Null ) %>
9 }
10 // This is the final execution.
11 // The data here is not visible in the background. The returned results are returned after the server processes the data.
12 Function Receivedata (data)
13 {
14 // You can write it as needed.
15 Alert (data );
16 }
17
18 < / SCRIPT>

3. Let's go to the background to see what the background receives.

Before writing, make preparations and first implement the icallbackeventhandler interface.

It automatically generates its own internal Method

Reprinted please specify http://netsos.cnblogs.com/

Code

1 # Region Icallbackeventhandler Member
2
3 Public   String Getcallbackresult ()
4 {
5 Return   "" ;
6 }
7
8
9 Public   Void Raisecallbackevent ( String Eventargument)
10 {
11
12 }
13
14 # Endregion

4. define a global variable for processing

Reprinted please indicate the source of [http://netsos.cnblogs.com]

 

Code

1 Private   String Callserverdata = String . Empty;
2 # Region Icallbackeventhandler Member
3
4 // He will use the passed results as the receivedata (data) parameter in the receivedata function just now ),
5 // Equivalent to data = getcallbackresult ()
6 Public   String Getcallbackresult ()
7 {
8 Return Callbackvaue +   " OK! " ;
9 }
10
11
12 Public   Void Raisecallbackevent ( String Eventargument)
13 {
14 This . Callserverdata = Eventargument;
15 // Remember that eventargument is the value of the ARGs variable at the front end.
16 // After receiving ARGs ---> eventargument ----> callserverdata
17 }
18
19 # Endregion

Summary:

The Calling sequence of the entire process is as follows: (foreground)Callback() -->

(Background) icallbackeventhandler. raisecallbackevent (string eventargument) -->

(Background) icallbackeventhandler. getcallbackresult () -->

(Front-end) receiveserverdata (string value ).

 

Reprinted please indicate the source of [http://netsos.cnblogs.com]

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.