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() { //...such as calculating a certain value }
2. How to access C# variables in JavaScript?
The answer is as follows:
Method 1: 1. Access
Method 2: 1. If PUBLIC STRING N is defined in the background; the format for referencing this variable in the front-end js is' <%=n%>' or " <%=n%> ; "
Method 3: 1. Or you can register a script on the page after assigning values to server-side variables
" "
tmp is a background variable, and then you can directly access temp in js to get the value.
3. How to access existing variables of JavaScript in C#?
The answer is as follows:
Method 1: 1. Use static text control to hide the field in the frontend and change the js variable Write the value into it;
2. Use request["id"] in the background to get the value;
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