Redshelf
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
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
Just additional comment from my previous post, you can use Navigate method to use a physical path something like
WebBrowser1.Navigate("WebB rowser1.Na vigate("C: \YourFile. xml"))
WebBrowser1.Navigate("WebB
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?
ASKER
VS2008
OK. Under "All Windows Forms" tab, the last control in there should be "WebBrowser"
ASKER
i cant find "All Windows Forms.
I ahve only, Standart,data,validation,n avigation, login.webp arts,AJAX extensions,reporting, html and general in my tool box.
where i can find "All Windows Forms" tab ?
I ahve only, Standart,data,validation,n
where i can find "All Windows Forms" tab ?
ASKER
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?
ASKER
I have managed to open XML file into new window using following code on button click.
str = "<script type='text/javascript'>det ailedresul ts=window. open('" & "../shared/" & strpath & "/test.xml" & "'" & "," & docname & " );</script>"
ClientScript.RegisterStart upScript(M e.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
str = "<script type='text/javascript'>det
ClientScript.RegisterStart
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/blu eWave.JPG" )
Dim path As String = Server.MapPath("../Images/ blueWave.J PG")
Dim path As String = Server.MapPath("~/Images/b lueWave.JP G")
Dim path As String = Server.MapPath("Images/blu
Dim path As String = Server.MapPath("../Images/
Dim path As String = Server.MapPath("~/Images/b
Here is more information about Server.MapPath
http://msdn.microsoft.com/en-us/library/ms524632%28VS.90%29.aspx
http://msdn.microsoft.com/en-us/library/ms524632%28VS.90%29.aspx
ASKER
thansk
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can use a Web Browser Control and then use WebBrowser1.Navigate method to open the XML file.