Image is not displayed in a Modal Pop Window using javascript and asp.net -
basically, trying develop aspx page user able upload image, display in modal pop window , crop if required.
if display image outside of pop window works fine, if try display inside of pop window image not displayed. however, have noticed if keep image there , remove <asp:image id="imgcrop"
javascript below, image displayed , off course not allow me crop it.
here javacripts use display modal popwindow , set crop settings:
<head runat="server"> <title>crop image</title> <link href="styles/jquery.jcrop.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript" src="scripts/jquery.jcrop.js"></script> <script type="text/javascript" src="scripts/jquery.helper.js" ></script> <link href="styles/style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> jquery(document).ready(function () { jquery('#imgcrop').jcrop({ onselect: storecoords }); }); function storecoords(c) { jquery('#x').val(c.x); jquery('#y').val(c.y); jquery('#w').val(c.w); jquery('#h').val(c.h); }; </script> </head>
here definition of modal pop window , want see image cropped in <asp:image id="imgcrop"
<input class="button_popup" id="btnshowmodaldiv" onclick="$('#divsimplepopup').showmodal(); return false;" type="submit" value="show modal div"/> <div id="divsimplepopup" class="popup" style="display: none; width: 350px;"> <div class="container"> <div class="header"> <span id="lblpopupheader" class="msg">simple popup header</span> <a id="btnclosepopup" class="close" onclick="$('#divsimplepopup').hidemodal(); return false;" ></a> </div> <div> <div class="body" style="height: 100px; overflow: auto;"> <asp:panel id="pnlcrop" runat="server" visible="false"> <asp:image id="imgcrop" runat="server" /> <br /> <asp:hiddenfield id="x" runat="server" /> <asp:hiddenfield id="y" runat="server" /> <asp:hiddenfield id="w" runat="server" /> <asp:hiddenfield id="h" runat="server" /> <asp:button id="btncrop" runat="server" text="crop" onclick="btncrop_click" /> </asp:panel> </div> <div class="footer"> <input class="button_popup" id="btnok" style="width: 40px;" type="submit" value="ok"/> <input class="button_popup" id="btncancel" onclick="$('#divsimplepopup').hidemodal(); return false;" type="submit" value="cancel"/> </div> </div> </div> </div>
source code , references: http://geekswithblogs.net/vladimirl/archive/2009/12/20/jquery-simple-modal-plugin.aspx http://supershope.com/tuvianblog/cropimage.zip
does has hint?
<asp:image id="imgcrop" runat="server" />
your image have runat="server" may have different id when rendered.
so need have following in page.
jquery(document).ready(function () { jquery('#<%= imgcrop.clientid %>').jcrop({ onselect: storecoords }); });
apart you've visible="false" on panel shown in below code:
<asp:panel id="pnlcrop" runat="server" visible="false">
so whole panel won't rendered , jquery code won't work. rather use style="display:none", panel rendered , image , plugin work.
Comments
Post a Comment