You can write a function in the background code and call it on the client. Like what:
[Ajax.ajaxmethod ()]
public int Serversideadd (int firstnumber, int secondnumber)
{
return firstnumber + secondnumber;
}
Here [Ajax.ajaxmethod ()] This sentence must be added. Otherwise there is no way to use the client.
This way, the Serversideadd method can be used directly on the client. Like what:
function Add2 ()
{
var re=webform1.serversideadd (Form1.first.value,form1.second.value)
Form1.result.value =re.value;
}
We can see in JS, this service side of the method before also with a WebForm1, this is the page corresponding class name.
TXT file in the example just let you understand some of the role of Ajax, of course, there are more powerful. As a method used by the client, the return value can be not only a generic type such as int, string, but also a complex type such as a DataSet and class, which also provides the potential for "strong JavaScript" for the client, allowing developers to " Object-oriented "development.
At the same time, no refresh in Ajax is one of its bright spots. The famous component Componentart a new 3. 0 products, there are call-back components, you can try if you are interested.
Of course, Microsoft also has Ajax products: Atlas
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.