writing XML to screen (like opening XML in IE)

  • Thread starter Thread starter Mike P
  • Start date Start date
M

Mike P

I have an XML file, which I want to write the screen (in its standard
XML format) in my ASP.NET C# webpage. Can anybody tell me how to do
this?
 
- write it to disk
( see the other thread you started )
- open the new file in another instance of explorer.
call some javascript that calls window.open() function on that new xml
file

string szScript = "";
szScript += "<SCRIPT language=javascript>\r\n";
szScript += " window.open('<<XMLFileName.xml', '_blank',
'width=700,height=450,top=100,left=100,toolbar=no,scrollbars=no,status=no,re
sizable=yes', 'true');\r\n";
szScript += "</SCRIPT>";
RegisterClientScriptBlock("SetupTable", szScript);


hope that helps.
Dan.



I have an XML file, which I want to write the screen (in its standard
XML format) in my ASP.NET C# webpage. Can anybody tell me how to do
this?
 
Dan,

Thanks for your help. Your javascript is almost the sort of thing I
want to do, but I need to open a file whose name will be dependent on a
variable i.e. in C# this would be "xmlfile" + lngFileNumber + ".xml".

How would I do this in javascript?


Cheers,

Mike
 
Mike,

That's no problem, remember that this code exists in the code behind c#
file, where you construct the javascript string you'd like to run on the
next page refresh.

string szFilename = "xmlfile" + lngFileNumber.ToString() + ".xml";
// code to save the xml file here
// StreamWriter wrtr = File.CreateText (szfilename) etc etc...

// script string generation code
string szScript = "";
szScript += "<SCRIPT language=javascript>\r\n";
szScript += " window.open('" + szfilename + "', '_blank',
'width=700,height=450,top=100,left=100,toolbar=no,scrollbars=no,status=no,re
sizable=yes', 'true');\r\n";
szScript += "</SCRIPT>";
RegisterClientScriptBlock("SetupTable", szScript);


adjust the javascript parameters as you need to for the screen size etc...

Dan.


Dan,

Thanks for your help. Your javascript is almost the sort of thing I
want to do, but I need to open a file whose name will be dependent on a
variable i.e. in C# this would be "xmlfile" + lngFileNumber + ".xml".

How would I do this in javascript?


Cheers,

Mike
 
Back
Top