JS calls the background, the background calls the frontend, etc. Summary
1. Execute the function in the C# code in the javaScript function:
Method 1: 1. First establish A button writes the calling or processing content into Button1_Click in the background;
protected void Button1_Click(object sender, EventArgs e) { this.TextBox1.Text = "voodooer"; }
2. It can be called like this in the foreground:
<input type="button" value="访问C#的方法" onclick='document.getElementById("Button1").click();' />
Method 2: 1. The function is declared as public or protected
public string ss() { return("voodooer"); }
2. Foreground calling method
<script language=javascript> var a = " <%=ss()%>"; alert(a); </script>
Method three: 1. ");
Method 2: Use Literal class, then
private void Button2_Click(object sender, System.EventArgs e) { string str; str=" <script language='javascript'>"; str+="selectRange()"; str+=" </script>"; //Literal1.Visible=true; Literal1.Text=str; }
The above is the detailed content of Summary of how javascript calls front and back method instances. For more information, please follow other related articles on the PHP Chinese website!