0

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

4 Comments

I tried both __doPostBack('<%= save.ClientID %>',''); and __doPostBack('lnkChange_OnClick',''); but none called the server side code
It will not be raising the server side event. It will got to Page_Load, from there you call your method.
And how can I analyse it in page_load so I can call the function I need? Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.