savefiledialog for webforms

  • Thread starter Thread starter kollatjorva
  • Start date Start date
K

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