为什么不IFRAME更新整个窗体asp.net的MVC [英] why iframe not updating the entire form asp.net mvc

查看:274
本文介绍了为什么不IFRAME更新整个窗体asp.net的MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关文件上传,我用的iframe,我的JavaScript像这样

for fileupload i used iframe,I have javascript like this

 function uploadFileUsingAnIframe(iFrame_id, form_id) {
            var iframe = document.createElement("iframe");
            iframe.setAttribute("id", iFrame_id);
            iframe.setAttribute("name", iFrame_id);
            iframe.setAttribute("width", "0");
            iframe.setAttribute("height", "0");
            iframe.setAttribute("border", "0");
            iframe.setAttribute("style", "width: 0px; height:0px; border: none;");

            document.body.appendChild(iframe);
            document.getElementById(form_id).target = iFrame_id;

        }

和在视图/ ASPX为

and in the view/aspx as

<% using (Html.BeginForm("AddFile", "uploadfile", FormMethod.Post, new
   {
       id = "uploadform",
       enctype = "multipart/form-data",
       target = "uploadFileFrame",
       onsubmit = "javascript:uploadFileUsingAnIframe('uploadFileFrame','uploadform');"
   })) 

%>

{ %>
<input type="file" id="addedFile" name="addedFile" /><br />
    <input type="submit" id="addfile" value="Addfile" />
          <div id="upload">
       //here i show the uploaded filenames from model </div>

<%} %>

问题是div没有显示最新手段的观点并没有更新模型值,可能是目标或参数传递给JavaScript函数需要改变以获得所需的视图。你们可以帮我了。

problem is the div is not showing latest means the view is not updating the model values ,may be the target or the parameters to be passed to the javascript function need to be changed to get required view. guys could you help me out.

感谢您,
michaeld

thank you, michaeld

推荐答案

您可以使用Valums上传。这是非常好的上传的js库,可以很容易地定制,而且已经有iframe的文件上传功能。

You can use Valums Uploader. It's very good upload js library that can be easily customized and already have iframe file upload functionality.

http://valums.com/ajax-upload/

这篇关于为什么不IFRAME更新整个窗体asp.net的MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆