开发者

why iframe not updating the entire form asp.net mvc

开发者 https://www.devze.com 2023-03-16 04:43 出处:网络
for fileupload i used iframe,I have javascript like this function uploadFileUsingAnIframe(iFrame_id, form_id) {

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;

        }

and in the view/aspx as

<% using (Html.BeginForm("AddFile", "uploadfile", FormMethod.Post, new
   {
       id = "uploadform",
       enctype = "multipart/form-data",
       target = "uploadFileFrame",
       onsubmit = "javasc开发者_运维知识库ript: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>

<%} %>

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.

thank you, michaeld


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消