Method 1: Directly use <%=%> to call
Front-end JS:
Back method:
public static string BehindMethod()
> return "This is a background method";
Method 2: Use ajax to call
Front-end js:
Copy code
The code is as follows:
Page html:
Copy code
The code is as follows:
Copy code
StringComparer SC = Ignorecase; string[] extArr = new string[] { "php", "asp", "aspx", "txt", "bmp" }; , EXT); // Determine whether there is a
if (f)
{
Return "Image/54222860.jpg"; image/star1.jpg";
}
Method 3: AjaxPro (also ajax)
Step one: Download AjaxPro.dll (or AjaxPro.2.dll) and add a reference to the project
Step 2: Modify the configuration file web.config
Copy code
The code is as follows:
Step 3: Register AjaxPro at runtime in the Page_Load event. Such as:
Copy code
The code is as follows:
Step 4: Create the server method and mark it with [AjaxPro.AjaxMethod]
Copy code
The code is as follows:
Copy code
The code is as follows:
function GetMethodByAjaxPro() {
var a = JustTest .AjaxDemo.GetImgByAjaxPro();//JustTest is the current namespace, AjaxDemo represents the background class document.getElementById("imgAjaxPro").src = a.value; >