Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
JavaScript
<script language="javascript" type="text/javascript">
    $("#ctl00_ContentPlaceHolder1_DataList1_ctl00_gallery").click(function() {
       
        $("#ctl00_ContentPlaceHolder1_DataList1_ctl00_FileUpload1").click();
    });

   
</script>


asp.net#
<asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" RepeatColumns="4" width="100%">
     <ItemTemplate>	
     
     <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>

    <td align="center"><asp:ImageButton ID="gallery" 
    ImageUrl='<%# Eval("photo_name") %>'  runat="server"   width="180" height="200" 
            CssClass="img-responsive img-thumbnail" onclick="gallery_Click" />
      <asp:Label ID="imageid" runat="server" Text='<%#Eval("proimg_id") %>' Visible="false" ></asp:Label>
   <asp:Label ID="userid" runat="server" Text='<%#Eval("user_id") %>' Visible="false"  ></asp:Label> 
    </td>
    <div  style="display:none;" >
        <asp:FileUpload ID="FileUpload1" runat="server"  />
    </div>
         
  </tr>
  
 
          </table>
		 
   
</ItemTemplate>
   </asp:DataList>


i am using for open new window in file upload.Here my code is not properly worked.My ques is how to use open the file upload dialoge box onclick the image
Posted
Updated 26-Feb-15 0:04am
v3

1 solution

I think you wanted to display the form, not trigger a click event on it. You can try this following code for that,

JavaScript
// Upon click on the element with ID gallery
$("#gallery").click(function() {
    // Show the element with ID FileUpload1
    $("#FileUpload1").show();
});


More specifically (since you're hiding the element parenting this control then the code would be like)

JavaScript
// Upon click on the element with ID gallery
$("#gallery").click(function() {
    // Show the element that is parent of element with ID FileUpload1
    $("#FileUpload1").parent().show();
});


Above code would change the display property of the element that matches this selection; selection is the element that is parenting the element with the ID FileUpload1. The jQuery parent function can be read about here[^].

In jQuery the click[^] function, triggers a click event. It might not be noticable through the GUI, but the underlying code would trigger as if an actual mouse click were triggered over the element.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900