I want to call button click event of c# code in my javascript function without clicking on button
thanks in advance.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rahul SinghRank #1,323 · 1.3K reputationPosted Jan 4, 2015, 11:31 PM EST
I am considering even if you don't have a separate event handler you want to trigger ASP.NET button click without manually clicking the button through code.
Consider we have two buttons:-
And correspoing Button click handler for TestButton as:-
protected void TestButton_Click(object sender, EventArgs e)
{
Response.Write("Hello");
}
You can call this through JS function like this:-
function fnTest() {
var dontClickButton = document.getElementById("TestButton");
dontClickButton.click();
}
Abhishek KumarRank #510 · 4.8K reputationPosted Jan 2, 2015, 7:03 AM EST
type="text/javascript"> function fncsave() { document.getElementById('').click(); } id="btnsave" onclick="fncsave()">Save This may help. AbhishekArjunan SelvamRank #2,179 · 651 reputationPosted Jan 1, 2015, 11:52 PM EST
Sharad GuptaRank #111 · 20K reputationPosted Jan 2, 2015, 12:51 AM EST
i use a html control and on click of that html control i want to process that functionality as i asked.
Thanks
Rahul SinghRank #1,323 · 1.3K reputationPosted Jan 4, 2015, 8:08 PM EST
Your question is not clear, I assume you want the server side button click event handler to be executed without clicking the button? But you need some event for that right? So my question is do you have any other event attached?
Sharad GuptaRank #111 · 20K reputationPosted Jan 5, 2015, 1:36 AM EST
thanks for your code
can we allow that process on li click, do you have any idea about it.
Rahul SinghRank #1,323 · 1.3K reputationPosted Jan 5, 2015, 2:48 AM EST
Sharad GuptaRank #111 · 20K reputationPosted Jan 5, 2015, 11:47 PM EST
your code is working perfectly now i am done with my problem.