Anton Belev
Anton Belev

Reputation: 13533

ASP fileupload control cannot be opened with Jquery in IE and Opera

I have the following problem when I'm browsing with IE 9 and Opera: I have a hidden aps fileupload dialog, which I trigger when the user clicks on an asp button.

<asp:LinkButton ID="btnBrowse" class="button fright marl10" OnClientClick="return openFileDialog()" runat="server" CausesValidation="false"></asp:LinkButton>

And here is the Jquery:

function openFileDialog() {
    $('#uploadPhotoDialog').click();        
    return false;
}

uploadPhotoDialog is the ID of the aps fileupload control.

I'll appreciate any answers. Thanks in advance.

Upvotes: 1

Views: 486

Answers (2)

J. Steen
J. Steen

Reputation: 15578

With the fileupload, specifically, there are security and sandboxing issues. I know that there are some things the fileupload will not respond to, such as programmatic clicking, to prevent auto-uploaders and such security shenanigans.

Upvotes: 1

Andreas
Andreas

Reputation: 2366

I'm just guessing now since I don't see the source code of the page and I don't know if this is the problem.

You are using an ID to select the element. The ID changes when you are using server-tags. What if you add ClientIDMode="Static" to the upload control (You must be using .net 4.0 )? That way the id doesn't change as it does when you are using server-tags per default.

See retrieve ID of server control using jQuery for more info how to select elements with jquery when usign server-tags.

Upvotes: 0

Related Questions