Javascript 为什么iframe不更新整个表单asp.net mvc
对于文件上传,我使用了iframe,我有如下javascriptJavascript 为什么iframe不更新整个表单asp.net mvc,javascript,asp.net-mvc,iframe,file-upload,upload,Javascript,Asp.net Mvc,Iframe,File Upload,Upload,对于文件上传,我使用了iframe,我有如下javascript function uploadFileUsingAnIframe(iFrame_id, form_id) { var iframe = document.createElement("iframe"); iframe.setAttribute("id", iFrame_id); iframe.setAttribute("name", iFrame_id);
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');"
}))
{%>
//这里我显示了从模型上传的文件名
问题是div没有显示最新的视图,这意味着视图没有更新模型值,可能是目标,或者传递给javascript函数的参数需要更改以获得所需的视图。伙计们,你们能帮我一下吗
谢谢,,
michaeld您可以使用Valums Uploader。这是一个非常好的上传js库,可以轻松定制,并且已经具有iframe文件上传功能
您可以使用Valums Uploader。这是一个非常好的上传js库,可以轻松定制,并且已经具有iframe文件上传功能
上传器是好的插孔,但我的要求是在没有任何插件的情况下尝试。上传器是好的插孔,但我的要求是在没有任何插件的情况下尝试。
{ %>
<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>
<%} %>