Summary of Asp.net AJAX calling background static methods

高洛峰
Release: 2016-12-16 16:21:34
Original
1565 people have browsed it

1.Ajax Library method

C# code:

[WebMethod]
public static DateTime GetCurrentTime(string str)
{
return DateTime.Now;
}

JS code:


                                                                function GetCurrentTime1()                                                                                                       
function CheckIsSuccess( result) {
            alert(result);
          }
   
                                                              using           use using ’s ’s using ’s ScriptManager ID="ScriptManager's-run's t---result of ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">

                                                                                                                                                                                                                              <


Note:

The C# method must add "[WebMethod]"

The front page must use the reference server control

Calling method: PageMethods.Background method name (parameter [, parameter....], method name called after success);

Ajax Library


2. jQuery method

C# code :

[WebMethod]

public static string ABC(string ABC)

{

return ABC;
}


JS code:

$().ready(
)       $("# AjaxDemo "). Click (function () {
$ .ajax ({

type:" post ",

url:" default.aspx/abc ",

data:" {'abc': 'test'} ",

contentType: "application/json; charset=utf-8",                                                                                                                                                                                                 }
            )


Note: The jQuery library file must be quoted.

3. There is another method that seems to refer to the AJAX.dll file. Register the front-end method in the background. This seems to be used more in .net2.0. I haven’t studied it carefully.






More For summary of multiple Asp.net AJAX calls to background static methods, please pay attention to the PHP Chinese website for related articles!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template