Link to home
Start Free TrialLog in
Avatar of Redshelf
RedshelfFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How to open XML file in a new Browser Window in VB.NET?

I have a page which opens the diffredt uploaded docs(.doc,.xls,.xml,.csv etc) from Server.

Now i want to open this docs from my application.. . i can open .doc, .xlx, .jpg etc. .. but i cant open .xml.
How do i open the .xml file from m y application.

right now i use  Shell("file:\\../shared/" & strpath & "/" & CStr(docname) & ext)

but it gives me an error  "file not found", but fiel is there in same folder.

Regards
Nitesha
Avatar of Alfred A.
Alfred A.
Flag of Australia image

Hi,

You can use a Web Browser Control and then use WebBrowser1.Navigate method to open the XML file.
Just additional comment from my previous post, you can use Navigate method to use a physical path something like

WebBrowser1.Navigate("WebBrowser1.Navigate("C:\YourFile.xml"))
Avatar of Redshelf

ASKER

how do i add Web Browser control in my projetc. I have added Microsoft Web Browser COM component from tools ..but i can not see it in my tool box. where i  can find it?
What is the version of Visual Studio you are using VS2005 or VS2008?
VS2008
OK.  Under "All Windows Forms" tab, the last control in there should be "WebBrowser"
i cant find "All Windows Forms.

I ahve only, Standart,data,validation,navigation,login.webparts,AJAX extensions,reporting, html and general in my tool box.

where i can find "All Windows Forms"  tab ?
Is there any way i can create and use it  using  code behind..?
Can you please clarify?  Are you doing an ASP.NET (Web application) Project or VB.NET (Windows Application) project?
If you are using ASP.NET, check this out.  It can help.

http://support.microsoft.com/kb/315906
I have  managed to open XML file into new window using following code on button click.

 str = "<script type='text/javascript'>detailedresults=window.open('" & "../shared/" & strpath & "/test.xml" & "'" & "," & docname & " );</script>"
 ClientScript.RegisterStartupScript(Me.GetType(), "AvisoScript", str)

but i have a another problem now..
if strpath is like "\cat1\cat2" then it removes  back slash ( \ ) from the path. so it tries to open cat1cat2/test.xml. so i receive the error File not found.
 it should be cat/cat2/test.xml.  

Do you ahve any idea why it remove \ from strpath strin varible which stores the part of the path .

i have .aspx page and .aspx.vb page for my code behind.

Nitesha
OK.  Use Server.MapPath to get the actual path for example.

Dim path As String = Server.MapPath("Images/blueWave.JPG")
Dim path As String = Server.MapPath("../Images/blueWave.JPG")
Dim path As String = Server.MapPath("~/Images/blueWave.JPG")

thansk
ASKER CERTIFIED SOLUTION
Avatar of Redshelf
Redshelf
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial