Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Dynamic TreeView XML Error in C#

Posted on 2005-04-12
Medium Priority
Last Modified: 2008-01-09
I'm using the standard TreeView control in an aspx page. I'm trying to load the contents of the tree from an xml file. This works fine when I use a static xml file (test.xml):

<iews:TreeView runat="server" AutoPostBack="true" ID="Treeview1">
<iews:treenode Text="test.xml" TreeNodeSrc="/Controls/test.xml" >

Unfortunately, I need to create the xml dynamically, so I'm trying to generate it with an aspx page (test.aspx), and load it like this:

<iews:TreeView runat="server" AutoPostBack="true" ID="Treeview1">
<iews:treenode Text="test.xml" TreeNodeSrc="/Controls/test.aspx" >

When I use test.aspx, I get an error:

"System.Exception: The XML loaded from TreeNodeSrc=http://localhost/SkyArc/Players/Controls/test.aspx, TreeNodeXslSrc= did not contain the required outer <TREENODES> container."

I have copied the output from test.aspx into test.xml, so if I point my browser directly at each file, their source looks IDENTICAL:

<?xml version="1.0" encoding="utf-8" ?>
      <treenode Text="363 Market" CHECKBOX="true" ></treenode>
      <treenode Text="363 Market" CHECKBOX="true" ></treenode>
      <treenode Text="Ohio" CHECKBOX="true" ></treenode>

One more thing: I've loaded test.aspx into the TreeView sample project and pointed the tree at it in the same way. It worked fine. I feel like I'm taking crazy pills! Why should my other project be any different?

Is this a Page.Response.ContentType kind of issue? I've looked all over the internet for this error, and have found discussions about it in many places... and it's never actually solved. Any thoughts?

Question by:juicemonger
  • 3
LVL 25

Expert Comment

ID: 13766021
Try the following for the aspx XML page:

Page.Response.ContentType = "application/xml"

HTH, Nauman.

Author Comment

ID: 13767031
   I had tried setting ContentType to "text/xml", but neither that nor your suggestion made any difference.

I've noticed something new: I expect test.aspx to be generated when I expand the parent node. In fact, I placed a breakpoint in the codebehind Page_Load() and found that it is never reached when I expand the parent node. I see the error page before Page_Load is called. Of course, if I point the browser directly at test.aspx, Page_Load() is called (and broken) immediately.

Author Comment

ID: 13774241
Is it possible that it's a permissions issue? My web app requires a username and password. If I am not logged in, I cannot point my browser directly at test.aspx -- I am redirected to the login page. The error page I've been seeing indicates that I'm seeing a server issue, not a browser issue - is it possible that the server is looking for the page from a port (or something) that is not logged into the system and is thus not granted proper access?

Author Comment

ID: 13776308
Wooooooooooooooo! Solved it. After 3 days.

When the TreeView Control requested test.aspx, it was doing so without authorization, so it was being redirected to the login page. I added:

  <location path="test.aspx">
        <allow users="?" />

...to Web.config and everything worked.

So... tell me a joke and... win 500 points?

Accepted Solution

PAQ_Man earned 0 total points
ID: 13989061
PAQed with points refunded (500)

Community Support Moderator

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question