Home > Article > Web Front-end > The simplest way to call ASP.NET server-side methods from JavaScript
对于这样的问题,有很多解决方法,如果你返回的内容是简单的内容,如注册用户时候的验证信息,只需返回存在与否,那么可以采用下面最最简单的代码实现:
C# 代码
<%@ Page Language="C#" %>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
If you need to return complex objects, you need to serialize the objects. You can take the following simple method. When using this method, you need to pay attention to the following three points:
1. The background method must be marked with the [System.Web.Services.WebMethod] attribute;
2. The background method must be a static method of static type;
3. ScriptManager must be set with EnablePageMethods=" true".
ASPX Code
<%@ Page Language="C#" %>
"http://www.w3 .org/TR/xhtml1/DTD/xhtml1-transitional.dtd">