Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   TreeView Control - Basic Question with TreeNodeSrc (http://www.velocityreviews.com/forums/t775438-treeview-control-basic-question-with-treenodesrc.html)

Dennis Redfield 02-17-2005 07:49 PM

TreeView Control - Basic Question with TreeNodeSrc
 

Ok. I have the TreeView Control working correctly as long as I do not use
TreeNodeSrc. It seems that however I format the XML file used for
TreeNodeSrc I get back the same error message:
System.Xml.XmlException: The data at the root level is invalid. Line 1,
position 1.\

So what am I doing wrong? Details:


The xml is well formed - copied from MSDN samples and looks like:

<?xml version="1.0" encoding="utf-8"?>
<TREENODES>
<TreeNode Text="Contracts" Type="Folder"/>
</TREENODES>

the HTML fragment for the treeview looks like:

<iewc:treeview id="TreeView1" runat="server"
SelectExpands="True" AutoSelect="True"
SystemImagesPath="images/treeimages/"
TreeNodeSrc="xmlmadness.xml">
<iewc:TreeNodeType ImageUrl="images/folder.gif" Type="Folder"
ExpandedImageUrl="images/folderopen.gif"></iewc:TreeNodeType>
</iewc:treeview>
</iewc:treeview>

thanks.






Steven Cheng[MSFT] 02-18-2005 06:12 AM

RE: TreeView Control - Basic Question with TreeNodeSrc
 
Hi Dennis,

Welcome to ASPNET newsgroup.
From your description, it seems that you've encoutered an existing problem
of the IE webcontrol. When we use the TreeNodeSrc to specify a xml data
source, we need to configure the xml file (or the entire Virutal DIR) as
allow Anonymous.

In addition, we can also resolve the problem by specifying the
"TreeNodeSrc" via physical file path , for example:

private void Page_Load(object sender, System.EventArgs e)
{
this.TreeView1.TreeNodeSrc = Server.MapPath("./treebooks.xml");
this.TreeView1.DataBind();
}

set the treenodesrc at runtime via code. Hope helps.

Thanks & Regards,


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Dennis Redfield 02-18-2005 07:15 PM

Re: TreeView Control - Basic Question with TreeNodeSrc
 
Thanks for the swift response Steve. We have implemented for comments with
mixed response.

I set access to anonymous for the Type and Node XML files and the Web
Control will parse them and generate a correct browser html page. This
works for me, ONLY if I reference the
xml files in the HTML code itself as:
<iewc:treeview id="TreeView1"
TreeNodeSrc="XMLSafe.xml"
TreeNodeTypeSrc="NodeType.xml" {other attributes here}... />

I fail however when I attempt to use Page_Load using either of:

TreeView1.TreeNodeSrc=Server.MapPath("xmlsafe.xml" );
TreeView1.TreeNodeTypeSrc=Server.MapPath("NodeType .xml");
this.TreeView1.DataBind();

or

TreeView1.TreeNodeSrc="xmlsafe.xml";
TreeView1.TreeNodeTypeSrc="NodeType.xml";
this.TreeView1.DataBind();

In both cases no exception is generated but the output (browser) html page
contains no nodes and no node types! I know the page_event is wired
correctly because I am also coding:

TreeView1.Attributes.Add("onselectedindexchange",T reeView1.ClientID+"_onchan
ge();");

in the page_load event and this line is working as expected.

I must have some other setting wrong? if i use invalid file names for the
xml files I generate no exception?! (I am step debugging through this so I
know the lines are being executed). Is the call to DataBind insufficient?

thanks.

dlr




"Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
news:e6HiNDYFFHA.3612@TK2MSFTNGXA01.phx.gbl...
> Hi Dennis,
>
> Welcome to ASPNET newsgroup.
> From your description, it seems that you've encoutered an existing problem
> of the IE webcontrol. When we use the TreeNodeSrc to specify a xml data
> source, we need to configure the xml file (or the entire Virutal DIR) as
> allow Anonymous.
>
> In addition, we can also resolve the problem by specifying the
> "TreeNodeSrc" via physical file path , for example:
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> this.TreeView1.TreeNodeSrc = Server.MapPath("./treebooks.xml");
> this.TreeView1.DataBind();
> }
>
> set the treenodesrc at runtime via code. Hope helps.
>
> Thanks & Regards,
>
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>




Steven Cheng[MSFT] 02-21-2005 07:21 AM

Re: TreeView Control - Basic Question with TreeNodeSrc
 
Hi Dennis,

Seems a bit strange. Then, have you tried another means in my last message :

Enable anonymouse asscess for that xml file and still set the TreeNodeSrc
in the page inline?

You can use this means to confirm that there hasn't been any other problem
with your enviorment.

In addition, as for the code you provided

======================
TreeView1.TreeNodeSrc=Server.MapPath("xmlsafe.xml" );
TreeView1.TreeNodeTypeSrc=Server.MapPath("NodeType .xml");
this.TreeView1.DataBind();
=========================

Call "DataBind" is necessary. And where is your aspx page and the
xmlsafe.xml file? Are they in the same directory in your application or
what's their location under your web app's root folder? I'm still thinking
this should something with the path.
BTW, you can try using the Server.MapPath("~/subfolder/filename")
to reference the xml file since "~/" means from the application's root
dir.

HTH. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Dennis Redfield 02-22-2005 01:56 PM

Re: TreeView Control - Basic Question with TreeNodeSrc
 
Steve,

Here is what is happening:

I can successfully do the 'inline' method:
>Then, have you tried another means in my last message :
> Enable anonymouse asscess for that xml file and still set the TreeNodeSrc
> in the page inline?


Adding the xml data source dynamically within Page_Load is not happening
correctly however.
> TreeView1.TreeNodeSrc=Server.MapPath("xmlsafe.xml" );
> TreeView1.TreeNodeTypeSrc=Server.MapPath("NodeType .xml");
> this.TreeView1.DataBind();

this runs without any runtime error but no tree nodes are produced on the
output html page.
xmlsafe.xml is in the root of the web application (~/ now).
I wired the DataBind event of TreeView1 and when I single step through the
code in the debuger I can see that
TreeNodeSrc is assigned and the call to the DataBind Method results in the
DataBind event being fired, but it seems like dispite all this the xml file
of nodes is NOT being bound correctly to the control?!?

thanks in advance

dlr


"Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
news:QMKa6X%23FFHA.400@TK2MSFTNGXA02.phx.gbl...
> Hi Dennis,
>
> Seems a bit strange. Then, have you tried another means in my last message

:
>
> Enable anonymouse asscess for that xml file and still set the TreeNodeSrc
> in the page inline?
>
> You can use this means to confirm that there hasn't been any other problem
> with your enviorment.
>
> In addition, as for the code you provided
>
> ======================
> TreeView1.TreeNodeSrc=Server.MapPath("xmlsafe.xml" );
> TreeView1.TreeNodeTypeSrc=Server.MapPath("NodeType .xml");
> this.TreeView1.DataBind();
> =========================
>
> Call "DataBind" is necessary. And where is your aspx page and the
> xmlsafe.xml file? Are they in the same directory in your application or
> what's their location under your web app's root folder? I'm still thinking
> this should something with the path.
> BTW, you can try using the Server.MapPath("~/subfolder/filename")
> to reference the xml file since "~/" means from the application's root
> dir.
>
> HTH. Thanks,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>




Steven Cheng[MSFT] 02-23-2005 04:52 AM

Re: TreeView Control - Basic Question with TreeNodeSrc
 
Hi Dlr,

I'm sorry to hear that the problem still remains.
Have you tried creating another new web project and using the treeview in a
simple page?
Or if possible , you can also perform the sample test on some other box to
see whether it also
occurs.

BTW, does "enable Allow Anoymouse" help ?

If you feel necessary, I can also attached my test page and the TREEVIEW
(ie wecontrol)'s assembly to you so that you can test on it on yoru side.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)




Dennis Redfield 02-23-2005 01:40 PM

Re: TreeView Control - Basic Question with TreeNodeSrc
 
ok, steve. I will start a clean project and try again.
and YES, YES setting the ACL to allow anoynemous access AND coding the xml
file reference directly on the HTML attribute Works as advertised.

thanks.

dlr
"Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
news:5NHw9NWGFHA.2808@TK2MSFTNGXA02.phx.gbl...
> Hi Dlr,
>
> I'm sorry to hear that the problem still remains.
> Have you tried creating another new web project and using the treeview in

a
> simple page?
> Or if possible , you can also perform the sample test on some other box to
> see whether it also
> occurs.
>
> BTW, does "enable Allow Anoymouse" help ?
>
> If you feel necessary, I can also attached my test page and the TREEVIEW
> (ie wecontrol)'s assembly to you so that you can test on it on yoru side.
>
> Thanks,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
>




Dennis Redfield 02-23-2005 09:10 PM

Re: TreeView Control - Basic Question with TreeNodeSrc
 
ok, Steve. Strange but true! I opened a new project and started fresh. NOW
(?!) your code works correctly within the Page_Load event.

thank you.!
dlr
"Dennis Redfield" <dennis.redfield@acadia-ins.com> wrote in message
news:OyXmwzaGFHA.2564@tk2msftngp13.phx.gbl...
> ok, steve. I will start a clean project and try again.
> and YES, YES setting the ACL to allow anoynemous access AND coding the xml
> file reference directly on the HTML attribute Works as advertised.
>
> thanks.
>
> dlr
> "Steven Cheng[MSFT]" <v-schang@online.microsoft.com> wrote in message
> news:5NHw9NWGFHA.2808@TK2MSFTNGXA02.phx.gbl...
> > Hi Dlr,
> >
> > I'm sorry to hear that the problem still remains.
> > Have you tried creating another new web project and using the treeview

in
> a
> > simple page?
> > Or if possible , you can also perform the sample test on some other box

to
> > see whether it also
> > occurs.
> >
> > BTW, does "enable Allow Anoymouse" help ?
> >
> > If you feel necessary, I can also attached my test page and the TREEVIEW
> > (ie wecontrol)'s assembly to you so that you can test on it on yoru

side.
> >
> > Thanks,
> >
> > Steven Cheng
> > Microsoft Online Support
> >
> > Get Secure! www.microsoft.com/security
> > (This posting is provided "AS IS", with no warranties, and confers no
> > rights.)
> >
> >
> >

>
>




Steven Cheng[MSFT] 02-25-2005 01:11 AM

Re: TreeView Control - Basic Question with TreeNodeSrc
 
Thanks for your followup Dennis,

Seems there has something incorrect in your former projects. Anyway, glad
that nothing wrong with your ASPNET environment and you got it work again.
Also, if you meet any further problem later, please feel free to post here.

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



All times are GMT. The time now is 04:54 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.