tags:

views:

32

answers:

1

I have an ImageButton and a FileUpload controls in a child page of a master page. I would like to achieve something like when user click on the ImageButton, the browse file window will pop-up like what we did when we click on the Browse button of the FileUpload control.

How can call the browse file window of the FileUpload control when i click on the ImageButton?

A: 

have you tried this?

<script>
function browse() {
    document.getElementById('<%= FileUpload1.ClientID %>').click();
}
</script>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:ImageButton ID="ImageButton1" runat="server" OnClientClick="browse()"
    ImageUrl="http://stackoverflow.com/favicon.ico" />
y34h
return error: "Microsoft JScript runtime error: 'document.getElementById(...)' is null or not an object". My controls are inside a child page, is that matter?
WeeShian
i believe not. try this instead, on Page_Load: `ImageButton1.Attributes["onclick"] = string.Format("document.getElementById('{0}').click();", FileUpload1.ClientID);`
y34h