Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have been working on a custom fileupload control in asp.net. But it is to difficult to do it. I have come so far but I have problem that I cannot understand.

I am trying to hide fileupload control and display an image instead. wehn the user clicks the image, I want the upload file to pop up. I tried the same thing in html with jquery and it works, but it doesnt work in aspp.net

The uploadfile doesnt show up.

here is the html code - http://jsfiddle.net/ees2q/1/

here is the asp.net code:

 <asp:FileUpload ID="FileUpload1" runat="server" style="display:none" />
 <img id="upload_img" src="http://us.cdn1.123rf.com/168nwm/artlosk/artlosk1010/artlosk101000085/7909823-single-rectangle-upload-button.jpg" width="20px">
 <script>$(document).ready(function () { $('#upload_img').click(function () { $('#FileUpload1').click(); }); });</script>

Please help me to fix asp.net code to display the fileupload

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Try to use this:

 $("#<%=FileUpload1.ClientID %>").click(function(){
    $('#upload').click();
});
share|improve this answer
1  
Thank you very much. I always use clientid in my project but this time I couldnt think of it:) –  ayilmaz Feb 22 '13 at 8:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.