开发者

Trigger an asp.net LinkButton with javascript

I have a page configured to hide a FileUpload control, so when you click a button it shows the file upload windows and after you choose the file it automatically submits it to the server.

Ir order for this to work i created 2 linkbuttons and a file upload but only one of the buttons is visible. When you click the button it triggers the fileupload window and when the FileUpload control has a change it triggers the submit (invisible) button. The proble I'm having is that only the OnClientClick is being triggered and the server side code is not running

<script type="text/javascript">
document.getElementById('<%= button.ClientID %>').onclick = function () {
    document.getElementById('<%= fileupload.ClientID %>').click();
    return false;    
}

document.getElementById('<%= fileupload.ClientID %>').onchange = fu开发者_开发技巧nction () {
     document.getElementById('<%= save.ClientID %>').click();
}
</script>

The save button has a onclientclick to show a modal window and should send to server

OnClick="lnkChange_OnClick" OnClientClick="ShowModalDialog(0);"

Any way to fix this?


I think __doPostBack('','') will help you. Call _doPostBack function from your client side function. It will postback the page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜