Asp.net Callback technology callback learning notes and Callback learning notes

Source: Internet
Author: User
Tags connectionstrings

Asp.net Callback technology callback learning notes and Callback learning notes

. Aspx:

<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default. aspx. cs" Inherits = "_ Default" %> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <Html xmlns =" http://www.w3.org/1999/xhtml "> <Head runat =" server "> <title> No title page </title> <script type =" text/javascript "> // pass the function DoSearch () parameter to the server () {var firstName = document. getElementById ("TextBox1 "). value; CallServer (firstName, "") ;}// obtain the server's data function paieserverdata (txtUserInfo) {Results. innerHTML = txtUserInfo;} // set to execute setInterval ("DoSearch ()", 1000) every second ); </script> 

Simplified Version (lazy ):

<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default. aspx. cs" Inherits = "_ Default" %> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <Html xmlns =" http://www.w3.org/1999/xhtml "> <Head runat =" server "> <title> No title page </title> <script type =" text/javascript "> function OnCallBack (txtUserInfo, context) {Results. innerHTML = txtUserInfo ;}</script> 

Example 3:

<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default3.aspx. cs" Inherits = "Default3" %> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <Html xmlns =" http://www.w3.org/1999/xhtml "> <Head runat =" server "> <title> No title page </title> <script type =" text/javascript "> // method executed by the client // function Success (args, context) {message. innerHTML = args;} // The following method is the function Error () {message called when an exception occurs in the result of receiving server Method Processing. innerHTML = "An exception occurred! ";}</Script> 

C #-What is the principle and mechanism of callback? C #

: The callback function is the function called after a certain condition is triggered during the execution of the program. This requires the function pointer to find the function entry address through the function pointer, execute the callback function. In. net, delegation is used for implementation. Delegation is a secure encapsulation of function pointers. The method (parameter 1, parameter 2, callback function) is to set parameter 1, and parameter 2 passed to the callback function delegate is the security encapsulation of the function pointer before the function pointer is unsafe because of the method (parameter 1, parameter 2, callback function) maybe the callback function only accepts one parameter, or the parameter type is different ~ However. net delegate specifies the callback function signature, so it is safe. I only understand the multi-threading chapter in C #'s advanced programming. Then I have learned C ++ and disassembly to understand it. just show off.

C # Callback

Download proxy and callback application instance
Using System;
Using System. IO;
Using System. Net;
Using System. Net. Sockets;

Private void Loader1 (){
HttpWebRequest hrqt = (HttpWebRequest) WebRequest. Create ("msdn2.microsoft.com/zh-cn/default.aspx ");
Hrqt. Proxy = (IWebProxy) new WebProxy (proxyip_string, port_int );
IAsyncResult iar = (IAsyncResult) hrqt. BeginGetResponse (new AsyncCallback (ResponseCallback), hrqt );
}

Private void ResponseCallback (IAsyncResult rs ){
HttpWebRequest rqt = (HttpWebRequest) rs. AsyncState;
HttpWebResponse res = (HttpWebResponse) rqt. EndGetResponse (rs );
Stream strm = res. GetResponseStream ();
}

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.