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>

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

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...

<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?

commented: Thanks ... +1

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?

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

Ok.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.