Home All Groups Group Topic Archive Search About

savefiledialog for webforms

Author
26 Sep 2006 2:34 PM
kollatjorva
hi
I have a web page with displays informations from an xml. On the same
web page is a "save xml as" button and when the button gets fired, I
want to display a save as dialog for the user to save the xml in a file

on his client machine.
Is this possible to do, we have savefiledialog in winform but is there
any similar for webforms?
Any help wil be very much appreciated and if you can provide some code
examples I would be very happy woman!
Thanks

Author
27 Sep 2006 7:06 AM
Dmytro Lapshyn [MVP]
Hi,

This is done quite differently in Web Forms (the code is off the top of my
head, so don't take it as a literal example, this is rather a skeleton to
get you started):

void btnSave_Click(/* ...event args omitted for brevity... */)
{
  Response.Clear();
  Response.ContentType = "text/xml";
  Response.ContentEncoding = System.Text.Encoding.Unicode; // You will most
likely have to adjust that.
  Response.BinaryWrite(xmlByteArray); // You can also use Response.Write if
your XML should be sent to the client in Unicode
  Response.Flush();
  Response.End();
}

The client's browser will prompt the user whether the user wants to open the
XML file or save it to disk. If the user chooses to save the file to disk,
the browser will display the Save As... dialog.

--
Regards,
Dmytro Lapshyn [MVP]
http://blogs.vbcity.com/DmytroL

<kollatjo***@gmail.com> wrote in message
Show quote
news:1159281286.106065.142230@h48g2000cwc.googlegroups.com...
> hi
> I have a web page with displays informations from an xml. On the same
> web page is a "save xml as" button and when the button gets fired, I
> want to display a save as dialog for the user to save the xml in a file
>
> on his client machine.
> Is this possible to do, we have savefiledialog in winform but is there
> any similar for webforms?
> Any help wil be very much appreciated and if you can provide some code
> examples I would be very happy woman!
> Thanks
>

AddThis Social Bookmark Button