ASP.net 2.0 TreeView SelectExpand

  • Thread starter Thread starter Mimo169
  • Start date Start date
M

Mimo169

Hi,

For some reason I cannot get a parent node to perform the SelectExpand
behavior when clicked if I am defining a Url value in my Web.sitemap.
It works fine if I leave the Url field blank, but then it throws off my
SiteMapPath (bread crumb trail) because it won't show a clickable link.

I believe the reason is because when you navigate to a URL, it is not
performing a postback which normally triggers the SelectExpand
behavior.

There must be some custom code that I can use so that it navigates to
the URL **AND** performs the SelectExpand behavior.

I hope someone can help me with this. I've been going nuts trying to
figure it out and apparently it's a limitation of the control.

Thanks!

-Alex
 
We wrote some custom code to get this working.

I figured I would post it for anyone who is stuck like I was:


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
TreeView1.DataBind();
TreeView1.FindNode(SiteMap.CurrentNode.Title).Expand();
}
catch
{
}
}
}

Dropping this into your c# code behind page will do the trick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top