ASP. NET callback

Source: Internet
Author: User

Aspx:

<Head runat = "server">
<Title> test </title>
<SCRIPT type = "text/JavaScript">
1. Function getnumber (){
Usecallback ();

// Usecallback ("123", ""); with Parameters
};
4. Function getrandonnumberfromserver (textbox1, context ){
Document. Forms [0]. textbox1.value = textbox1
};
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Input id = "" type = "button" value = "get random number" onclick = "getnumber ()"/>
<Br/>
<Br/>
<Asp: textbox runat = "server" id = "textbox1" text = ""> </ASP: textbox>
</Div>
</Form>
</Body>
</Html>

Aspx. VB:

Partial class _ default
Inherits system. Web. UI. Page
Implements system. Web. UI. icallbackeventhandler
Dim _ callbackresult as string = nothing
Protected sub page_load (byval sender as object, byval e as system. eventargs) handles me. Load
Dim cbreference as string = page. clientscript. getcallbackeventreference (Me, "Arg", "getrandonnumberfromserver", "context ")
Dim cbscript as string = "function usecallback (ARG, context)" & "{" & cbreference &";"&"}"
Page. clientscript. registerclientscriptblock (Me. GetType (), "usecallback", cbscript, true)
End sub

3. Public Function getcallbackresult () as string implements system. Web. UI. icallbackeventhandler. getcallbackresult
Return _ callbackresult
End Function

2. Public sub raisecallbackevent (byval eventargument
As string) implements system. Web. UI. icallbackeventhandler. raisecallbackevent
'Eventargument is the parameter value passed by the foreground

_ Callbackresult = RND (). tostring
End sub


End Class

 

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.