【问题标题】:why iframe not updating the entire form asp.net mvc为什么 iframe 不更新整个表单 asp.net mvc
【发布时间】:2011-09-25 19:29:30
【问题描述】:

对于文件上传,我使用 iframe,我有这样的 javascript

 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 中作为

<% 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 函数的参数需要更改以获得所需的视图。伙计们,你能帮帮我吗?

谢谢你, 迈克尔

【问题讨论】:

    标签: javascript asp.net-mvc iframe file-upload upload


    【解决方案1】:

    您可以使用 Valums 上传器。非常好的上传js库,可以轻松定制,已经具备iframe文件上传功能。

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

    【讨论】:

    • 上传者是好插孔,但我的要求是不带任何插件尝试。
    猜你喜欢
    • 2011-03-29
    • 1970-01-01
    • 2011-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多