[Need help]: Issue with submit button and html file input control’s Click() method
Scenario: On click of a button, we dynamically create html file input (file upload) control on the page and call that file input controls Click() method. User then selects the file from the disk. There is a “Submit” button to upload the selected file.
Problem: The problem is, when 开发者_运维问答clicked on “Submit” button first time, the input value from the file input control is cleared. And the request does not go to the server. When clicked second time, the request goes to server with empty file input value.
Why the first click on submit button does not send the request to server. And why it clears the file input control value?
Note: The issue is observed only when we call Click() method programmatically. If we let user to click browse, then in that case, the "Submit" does not clear the input value and sends request to server on first click itself.
Any help would be appreciated. Thanks in advance.
By the way, server side code is in asp.net and client side in java script, testing on IE.
-Somesh
Can you inject some javascript from your code-behind that would call the client-side click() event on that file upload control? This would simulate the user clicking the submit button, which you know works.
This is more or less equivalent to your query: jQuery : simulating a click on a <input type="file" /> doesn't work in Firefox?
The thing that you are trying does not seem to be possible.
精彩评论