0

I want a file uploader,that doesnt cause post back in asp.net 2.0.
With some googleing i found that if i set traget of the form to an iframe on the same page,i can avoid post back.But when i try this the page is getting opened in new window.(ie7 is the browser i am using).

I understand that post back will happen anyway,but can we avoid the page getting opened in new window some how?

Please find my code below:

<form id="form1"  action="#" method="post" enctype="multipart/form-data" runat="server" target="myframe">
    <input type="file" id="myfile"   accept="image"  runat="server"/>
    <input type="submit" value="upload"  runat="server" />
    </form>
    <iframe id="myframe">
    </iframe>
3
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by Dhaneshnm
0

Hai,
Why you want to avoid the Postback? Is it to retain the upload path?
If its for retaining path you put one hidden control in the form and set the path to the hidden control so that you can use it again after postback.
If you really want to avoid the postback effect you can use Ajax update panel to prevent the page postback.
Hope this will help you.

thanks,
Shenu

0

Hai,
Why you want to avoid the Postback? Is it to retain the upload path?
If its for retaining path you put one hidden control in the form and set the path to the hidden control so that you can use it again after postback.
If you really want to avoid the postback effect you can use Ajax update panel to prevent the page postback.
Hope this will help you.

thanks,
Shenu

File upload control doesnt seem to work in an update panel.And what i want is an ajax like uploader,where file uploading doesnt disturb other controls of the page.I can use a Modal pop up,but that will be a new page,exclusively for upload right?

i want not just the path,but the whole content of the file send to the server,on click of submit.And that should not disturb anything outside the form...

1
<form id="form1"  action="#" method="post" enctype="multipart/form-data" runat="server" target="myframe">
    <input type="file" id="myfile"   accept="image"  runat="server"/>
    <input type="submit" value="upload"  runat="server" />
    </form>
    <iframe id="myframe" name="myframe">
    </iframe>

Does that work now?

Votes + Comments
Thanks ...
0

Kool.Its working fine now..Thanks a lot.
Can you explain why it was not working?
Whats the problem if use id instead of name?it wont recognise the iframe?

0

Firefox, Netscape Navigator and Opera will allow target to eather be an id= or a name= whereas IE only allows name= so I have both to cover all browsers

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.