Home >
Article > Web Front-end > Summary of function methods in C# code executed in javaScript function_javascript skills
Summary of function methods in C# code executed in javaScript function_javascript skills
WBOYOriginal
2016-05-16 17:26:261164browse
Method 1:
1. First create a button, and write the calling or processing content into button_click in the background; 2. Write a js function in the foreground with the content of document.getElementById("btn1").click(); 3. Call the js function in the foreground or background to trigger the click event, which is equivalent to accessing the background c# function; Method 2: 1. Declare the function as public Backend code (you can also change public to protected) The following is a quote fragment:
public Page_OnLoad() { if (!Page.IsPost()) { string strFunName=Request.Form["FunName"]!=null?Request.Form["FunName"]:""; //Determine which function to call based on the value passed back switch(strFunName) { case "enter()": enter() ; //Call this function break; case "other": //Call other functions break ; default: //Call the default function break; } } } public void enter() { //… For example, calculate a certain value }
Statement:
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