This is a migrated thread and some comments may be shown as answers.

LoadContentFile from URL

1 Answer 49 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 1
Jerry asked on 12 Oct 2020, 06:13 PM

Hello,

 

Is it possible to populate a TreeView control from an XML file that is on another web server?

I'm using the LoadContentFile to load the tree on the website where the XML file is located, but I'm not sure how to populate the TreeView on my other website that needs the same source.

I'm using the XML file on 2 different websites and wanted to use the one source. 

I currently get "is not a valid virtual path" error.

This is an example URL: https://temp.com/xml/temp.xml

Thank you

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 15 Oct 2020, 12:01 PM

Hi Jerry,

The implementation of the LoadContentFile() is based on the Context.Server.MapPath() method and as such can work only with virtual paths to files placed inside the application's root directory.

		public virtual void LoadContentFile(string xmlFileName)
		{
			string xml = File.ReadAllText(Context.Server.MapPath(xmlFileName));
			LoadXml(xml);
		}

If you have access to the file content from the page holding the TreeView, though, you can pass the xml data directly through the control's LoadXml method:
https://docs.telerik.com/devtools/aspnet-ajax/controls/treeview/data-binding/loading-xml-content#loading-from-an-xml-string

RadTreeView1.LoadXml("<Tree><Node Text="Books"/><Node Text="Music"/></Tree>");

Regards,
Vessy
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
TreeView
Asked by
Jerry
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or