I have been modifying the project recently. I saw that the previous developers used ajaxpro and used it myself,
1. Web. cofig add nodes
<System. Web>
<Httphandlers>
<Add verb = "post, get" Path = "ajaxpro/*. ashx" type = "ajaxpro. ajaxhandlerfactory, ajaxpro"/>
2Add references to the CS File
Using ajaxpro;
3. CS file loading event
Protected void page_load (Object sender, eventargs E)
{
Utility. registertypeforajax (typeof (Class Name ));
4. Add [ajaxpro. ajaxmethod] To the Cs method.
[Ajaxpro. ajaxmethod]
Public String getname (string selectvalue)
{
// Note: 1. return values are required; 2. Controls are not available in the method body; 3. It is best to have input parameters. Sometimes, the error "download of specified resource error" is reported"
// Error
Return selectvalue;
}
5. Front-end JS use
<SCRIPT type = "text/JavaScript" Language = "JavaScript">
Function Tan ()
{
VaR A = Class Name. getname ("1111"). value;
Alert ();
}
</SCRIPT>
6. Controls
<Input type = "button" id = "btn1" value = "Click here" onclick = "Return Tan ()"/>