How to call a code behinds button click event usin

2020-04-03 14:27发布

Is it possible to call a server side buttons click event using javascript or jquery If yes then how to do it

7条回答
Lonely孤独者°
2楼-- · 2020-04-03 14:57

yes, you can do it with the following code:

$('[id$=txtDOB]').live('blur', function (e) {
        $('[id$=btnsubmit]').click();
    });

The button's click fire on textbox(txtDOB)'s blur event. Hope this will help you.

查看更多
Summer. ? 凉城
3楼-- · 2020-04-03 15:01

in jquery

$("#button_id").click(function(){
// do something when button is clicked
});

and invoke the function with

$("#button_id").click();
查看更多
放荡不羁爱自由
4楼-- · 2020-04-03 15:04

call the click() of specified button which will trigger server side events too in web forms.

$("#idofbutton").click(); // whereever required to trigger the server click  event

Thanks

查看更多
▲ chillily
5楼-- · 2020-04-03 15:05

Lets say this is your html:

<input type="button" id="button" value="btn" />

In jquery, you invoke click of button as below:

$("#button").click();   //button is id

And in javascript:

document.getElementById("button").click();
查看更多
爱情/是我丢掉的垃圾
6楼-- · 2020-04-03 15:05

Yes, javascript can do that. I assume you are using ASP.Net

<asp:Button ID="button" runat="server" Text="Test" />

<script>
    document.getElementById("<%= button.ClientID %>").click();
</script>
查看更多
闹够了就滚
7楼-- · 2020-04-03 15:12
document.getElementById("Button1").click();
查看更多
登录 后发表回答