Pure skill, Master laughed at.
When it comes to how to call the backend C # method in the foreground JS, Ajax becomes an inevitable idea.
Just implement the details using AJAX 1.0 or Ajaxpro difference.
In fact, if not Ajax, we can easily use JS to invoke the backend method.
The steps are as follows:
1 Front desk put a button. Set to hidden. Note: You cannot set the Visible=false directly, so you cannot find this button in the ASP.net 2.0 compiled code. Need to set style: Style= "Display:none;"
2 Double-click the button, write to the C # method, or write a code snippet that calls other methods in the background
3 The front desk JS call, as follows, so you can simulate the click of the button event, triggering the background method:
document.getElementById ("Button2"). Click ();
Example
Asp. NET page:
<script>
function go()
{
document.getElementById("Button2").click();
}
</script>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="go();return false;" />
<asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" Style="display: none;" />
</div>
</form>
</body>