k ... Strager was able to help me a little. However, it still does not work. Need someone who knows both MVC and jQuery, please ...
I have a page with an image that, when clicked, will launch a dialog box that allows you to upload a file. After closing the dialog box, the image should be updated with what was loaded / saved in the database ...
Everything works great for the first time. However, if I try to upload a second image; 1st image is displayed. It also doesn't look like my controller method is called a second time ... Below is my code ...
I also ruled out that the page is cached. Again, the controller method is not called the second time around ...
controller
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult GetImage(Guid parentId)
{
var la = Helper.Service.GetAttachmentByEntity(parentId, MembershipProvider.SecurityTicket).ToList();
la.OrderByDescending(x => x.CreatedDate);
return File(la[0].Data, la[0].ContentType);
}
View
<script type="text/javascript">
$(function() {
var iphcObject = $('#<%=imagePlaceHolderControl.ClientID %>');
iphcObject.children().find('#imageUploadDialog').bind('onClose', function() {
iphcObject.children().find('#image').attr('src', '<%=Url.Action("GetImage", "Image", new { parentId = Model.ParentId }) %>');
});
});
</script>
<asp:Panel ID="imagePlaceHolderControl" runat="server">
<div style="border: solid 1px; width: <%=Model.Width%>; height: <%=Model.Height%>; text-align: center; vertical-align: middle;">
<a href="#" onclick="$('#imageUploadDialog').dialog('open');" title="Add a picture...">
<img id="image" src="<%=Url.Content("~/content/images/icon_individual_blank.gif") %>" /></a>
<%Html.RenderDialog("imageUploadDialog", "Upload image...", "ImagePlaceHolder_Upload", "Image", Model, 235, 335); %>
</div>
</asp:Panel>