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 = function () {
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.