Home > Web Front-end > JS Tutorial > Summary of how javascript calls front and back method instances

Summary of how javascript calls front and back method instances

伊谢尔伦
Release: 2017-07-18 14:38:06
Original
2004 people have browsed it

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"; 
}
Copy after login

2. It can be called like this in the foreground:

<input type="button" value="访问C#的方法" onclick=&#39;document.getElementById("Button1").click();&#39; />
Copy after login

Method 2: 1. The function is declared as public or protected

public string ss() 
{ 
return("voodooer"); 
}
Copy after login

2. Foreground calling method

<script language=javascript> 
var a = " <%=ss()%>"; 
alert(a); 
</script>
Copy after login

Method three: 1. ");

Method 2: Use Literal class, then

private void Button2_Click(object sender, System.EventArgs e) 
{ 
string str; 
str=" <script language=&#39;javascript&#39;>"; 
str+="selectRange()"; 
str+=" </script>"; 
//Literal1.Visible=true; 
Literal1.Text=str; 
}
Copy after login


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!

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