How to trigger C # code through javascript in Asp.net
Source: Internet
Author: User
I searched on the Internet and tried to call C # through JavaScript. CodeThere seems to be no direct method, but an indirect method can be used to trigger a click event of the hidden button through JavaScript code. The setting of the hidden button is as follows:
<Input id = "hiddenbutton" type = button style = "width: 0px; heightj: 0px" runat = server onserverclick = "hiddenbutton_serverclick" \>
Hiddenbutton_serverclick is a C # event-related function;
In this way, we can basically use it.
Note that the following must be used to trigger the hiddenbutton click event:
Document. All ("hiddenbutton"). Click ();
Instead of using: Hiddenbutton. Click ();
Using the following method will get stuck with object error. In fact, this 2 object cannot be found;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service