asp.net-刷新图像源

k … Strager能够帮助我一点.但是,它仍然无法正常运行.需要一个同时了解MVC和jQuery的人…

我有一个页面,其中包含一个图像,单击该图像将启动一个对话框,使您能够上传文件.对话框关闭后,图像应该使用数据库中上载/存储的内容进行刷新…

第一次一切都很好.但是,如果我尝试上传第二张图片;第一张图像仍然显示.我的控制器方法似乎也没有第二次被调用…下面是我的代码…

我还消除了页面被缓存的情况.同样,第二次未调用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);
}

视图

<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",Model,235,335); %>        
    </div>
</asp:Panel>
最佳答案
什么是#image不应该找到(‘img’)?或给IMG一个“图像”的ID.

相关文章

1.第一步 设置响应头 header(&#39;Access-Control-Allow...
$.inArray()方法介绍 $.inArray()函数用于在数组中搜索指定的...
jquery.serializejson.min.js的妙用 关于这个jquery.seriali...
JS 将form表单数据快速转化为object对象(json对象) jaymou...
jQuery插件之jquery.spinner数字智能增减插件 参考地址:http...