mousemat24
asked on
NavigateURL does not remember what you've selected in a Treeview
I really need somones help who has good knowledge in ASP.NET treeview. I'm using VS2005/C#
I have a treeview control, that is populated from a SQL db, all of the navigateURL has a URL. My problem is when I click on anyone of the URL's it dosnt remember what node I clicked on i.e. it dosnt highlight the node.
Can some one please help me in getting this to work i.e. when a user clicks on a URL, it hightlights the selected node.
Thank you
Mousemat24
I have a treeview control, that is populated from a SQL db, all of the navigateURL has a URL. My problem is when I click on anyone of the URL's it dosnt remember what node I clicked on i.e. it dosnt highlight the node.
Can some one please help me in getting this to work i.e. when a user clicks on a URL, it hightlights the selected node.
Thank you
Mousemat24
ASKER
No TheLearnedOne.
I have a treeview, all the nodes have a navigateURL prop assigned to it, so that when a user clicks on the selectednode, it opens up a new page. But the problem I'm having is the selected node isnt highlighted, so they dont know where they are in the menu?
Does that makes sense? if not, please let me know
mousemat24
I have a treeview, all the nodes have a navigateURL prop assigned to it, so that when a user clicks on the selectednode, it opens up a new page. But the problem I'm having is the selected node isnt highlighted, so they dont know where they are in the menu?
Does that makes sense? if not, please let me know
mousemat24
>>when a user clicks on the selectednode, it opens up a new page
Can you show me how you do this?
Bob
Can you show me how you do this?
Bob
ASKER
for (i = 0; i < tempFor1; i++)
{
if (Convert.ToInt32(ds.Tables [0].Rows[i ]["MNU_Par entNodeID" ]) == 0)
{
TreeNode tn = new TreeNode(ds.Tables[0].Rows [i]["MNU_D isplayName "].ToStrin g(), ds.Tables[0].Rows[i]["MNU_ URL"].ToSt ring(), "");
RecursivelyAddToNode(tn, Convert.ToInt32(ds.Tables[ 0].Rows[i] ["MNU_ID"] ), ds);
TreeView1.Nodes.Add(tn);
}
}
========================== ========== ========== ========== ====
private void RecursivelyAddToNode(TreeN ode mymenuitem, int ParentID, DataSet ds)
{
DataView dv = new DataView(ds.Tables[0]);
dv.RowFilter = ("MNU_ParentNodeID=" + ParentID.ToString());
foreach (DataRowView r in dv)
{
TreeNode tn = new TreeNode(r["MNU_DisplayNam e"].ToStri ng(), r["MNU_URL"].ToString(), "");
mymenuitem.ChildNodes.Add( tn);
RecursivelyAddToNode(tn, Convert.ToInt32(r["MNU_ID" ]), ds);
}
}
========================== ========== ========== ========== ======
protected void TreeView1_SelectedNodeChan ged(object sender, EventArgs e)
{
string valueOfTreenode = TreeView1.SelectedNode.Val ue;
string valueOfTreenodeIndexOf = valueOfTreenode.IndexOf("{ ").ToStrin g();
Label1.Text = TreeView1.SelectedNode.Val ue.ToStrin g();
if (Convert.ToInt16(valueOfTr eenodeInde xOf) == -1)
{
Response.Redirect(valueOfT reenode);
}
else
{
string getUnidOutFromValue = valueOfTreenode.Substring( valueOfTre enode.Last IndexOf("{ "));
Web_Ref.WebService getContent = new Web_Ref.WebService();
DataSet ds = new DataSet();
ds = getContent.displayContent( getUnidOut FromValue) ;
foreach (DataRow dr in ds.Tables[0].Rows)
{
content.InnerHtml = dr["CNT_Body"].ToString();
}
}
}
Hope that helps, really would like some help
{
if (Convert.ToInt32(ds.Tables
{
TreeNode tn = new TreeNode(ds.Tables[0].Rows
RecursivelyAddToNode(tn, Convert.ToInt32(ds.Tables[
TreeView1.Nodes.Add(tn);
}
}
==========================
private void RecursivelyAddToNode(TreeN
{
DataView dv = new DataView(ds.Tables[0]);
dv.RowFilter = ("MNU_ParentNodeID=" + ParentID.ToString());
foreach (DataRowView r in dv)
{
TreeNode tn = new TreeNode(r["MNU_DisplayNam
mymenuitem.ChildNodes.Add(
RecursivelyAddToNode(tn, Convert.ToInt32(r["MNU_ID"
}
}
==========================
protected void TreeView1_SelectedNodeChan
{
string valueOfTreenode = TreeView1.SelectedNode.Val
string valueOfTreenodeIndexOf = valueOfTreenode.IndexOf("{
Label1.Text = TreeView1.SelectedNode.Val
if (Convert.ToInt16(valueOfTr
{
Response.Redirect(valueOfT
}
else
{
string getUnidOutFromValue = valueOfTreenode.Substring(
Web_Ref.WebService getContent = new Web_Ref.WebService();
DataSet ds = new DataSet();
ds = getContent.displayContent(
foreach (DataRow dr in ds.Tables[0].Rows)
{
content.InnerHtml = dr["CNT_Body"].ToString();
}
}
}
Hope that helps, really would like some help
ASKER
TheLearnedOne
As you can see Im using a Response.Redirect(<ASPX FILE>). What I want is when a user clicks on that node it will open the page up (through the master page), and highlight the selectedNode. There must be a way to get this to work with a Response.Redirect
Thanks
As you can see Im using a Response.Redirect(<ASPX FILE>). What I want is when a user clicks on that node it will open the page up (through the master page), and highlight the selectedNode. There must be a way to get this to work with a Response.Redirect
Thanks
Hi, mousemat24
As I told, I'm not really working with ASP. And do not much care about points :)
As I pointed in the other toopic, when a node is in navigation mode (navigateURL is assigned), all selection events are disabled for that node.
Therefore the method 'TreeView1_SelectedNodeCha nged' shouldn't be invoked at all.
Did you try to NOT assign NavigateUrl but put you url into value property? Eventually you are reading the url from the value property in your method...
As I told, I'm not really working with ASP. And do not much care about points :)
As I pointed in the other toopic, when a node is in navigation mode (navigateURL is assigned), all selection events are disabled for that node.
Therefore the method 'TreeView1_SelectedNodeCha
Did you try to NOT assign NavigateUrl but put you url into value property? Eventually you are reading the url from the value property in your method...
ASKER
I've tried using the value, but when you do a redirect it dosnt know what you've selected.
Please see this:
http://channel9.msdn.com/ShowPost.aspx?PostID=110278
There must be a way to do this?
Please see this:
http://channel9.msdn.com/ShowPost.aspx?PostID=110278
There must be a way to do this?
Hmmm...
I'm not good enough in ASP, I told.
However what if you e.g. try to set session variable to the url, then redirect and set the selected node from this session variable?
Does it make sense at all?
I'm not good enough in ASP, I told.
However what if you e.g. try to set session variable to the url, then redirect and set the selected node from this session variable?
Does it make sense at all?
ASKER
I've done that, no luck, really need some help on this question
Thanks
Thanks
I give up.
Still check that navigateURL prop is set to blank string for ALL nodes. Otherwise I believe select mode is never working...
Still check that navigateURL prop is set to blank string for ALL nodes. Otherwise I believe select mode is never working...
Have you set the SelectedNodeStyle.ForeColo r/BackColo r for the TreeView?
Bob
Bob
ASKER
TheLearnedOne
the problem is, if the selected item is deep within a menu, it wont expand the menu, so if I can get that to work, maybe getting the SelectedNodeStyle.ForeColo r/BackColo r might work ok. This is really doing my brains in!! :-)
the problem is, if the selected item is deep within a menu, it wont expand the menu, so if I can get that to work, maybe getting the SelectedNodeStyle.ForeColo
If you don't set the SelectedNodeStyle, then you won't see the selected node, in order to verify that it is working.
Bob
Bob
ASKER
Just done thie Bob
TreeView1.SelectedNodeStyl e.BackColo r = System.Drawing.Color.Aqua;
It dosnt work when I have a Response.Redirect
TreeView1.SelectedNodeStyl
It dosnt work when I have a Response.Redirect
1) Are you using master pages?
2) When you do a Response.Redirect, is the TreeView still visible?
3) If you are using Response.Redirect, and not master pages, then usually the TreeView would no longer be visible, unless you have some other kind of magic.
Bob
2) When you do a Response.Redirect, is the TreeView still visible?
3) If you are using Response.Redirect, and not master pages, then usually the TreeView would no longer be visible, unless you have some other kind of magic.
Bob
ASKER
1) I'm using a masterpage
2) It is visible, but the menu gets collapsed, so my selectednode isnt highlighted
3) No magic - using a master page
Annoying problem isnt it
2) It is visible, but the menu gets collapsed, so my selectednode isnt highlighted
3) No magic - using a master page
Annoying problem isnt it
>>It is visible, but the menu gets collapsed, so my selectednode isnt highlighted
Can you explain this a little more, please? How does it get collapsed?
Bob
Can you explain this a little more, please? How does it get collapsed?
Bob
ASKER
Bob, I've set the menu prop to CollapseAll
TreeView1.CollapseAll();
The reason being I will have alot of menu options, so I want to Collapse it. As I mentioned it works with the rest of the menuNodes i.e. It opens up the correct menu and remembers what you clicked on.
When I'm pulling out information from SQL, I place the content into a literal control, content.innerHTML = <FROM SQL>
But there are other menus that point to another page i.e. ASPX. Because of this I have to use Response.Redirect, theres where it stops working.
Hope thats clear?
If not please let me know
mousemat24
TreeView1.CollapseAll();
The reason being I will have alot of menu options, so I want to Collapse it. As I mentioned it works with the rest of the menuNodes i.e. It opens up the correct menu and remembers what you clicked on.
When I'm pulling out information from SQL, I place the content into a literal control, content.innerHTML = <FROM SQL>
But there are other menus that point to another page i.e. ASPX. Because of this I have to use Response.Redirect, theres where it stops working.
Hope thats clear?
If not please let me know
mousemat24
If you don't collapse the TreeView, does it highlight the node correctly?
Bob
Bob
ASKER
No it dosnt Bob, it dosnt work with any response.redirect
Does it work with Server.Transfer? Do you need Response.Redirect?
Bob
Bob
ASKER
Nope sorry, I tried that too :-(
ASKER
Any other stuff I can do Bob?
Thanks
Thanks
You could try MaintainScrollPositionOnPo stback in the @Page directive:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TreeViewExample. aspx.cs" Inherits="TreeViewExample" MaintainScrollPositionOnPo stback="tr ue" %>
Bob
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TreeViewExample.
Bob
ASKER
TheLearnedOne
That too dont work, I placed that in one of my ASPX file that uses the Response.Redirect
:-(
That too dont work, I placed that in one of my ASPX file that uses the Response.Redirect
:-(
ASKER
Hi Bob
I think I found the answer!!!!
Go here and download the ZIP file
http://blog.binaryocean.com/2006/01/19/SaveTreeViewNodesExpansionCollapseStateCSAndVB.aspx
It expands, but I cant figure out how to highlight the selectedNode. Do you thanks you can help me?
thanks
I think I found the answer!!!!
Go here and download the ZIP file
http://blog.binaryocean.com/2006/01/19/SaveTreeViewNodesExpansionCollapseStateCSAndVB.aspx
It expands, but I cant figure out how to highlight the selectedNode. Do you thanks you can help me?
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Bob
Did you try the URL, that clearly show the problem, i.e. the selected node isnt highlighted, Can you help in getting the hightlighted node color to change
Thanks
Did you try the URL, that clearly show the problem, i.e. the selected node isnt highlighted, Can you help in getting the hightlighted node color to change
Thanks
Let's revisit an old comment:
Did you set the TreeView.SelectedNodeStyle with that new code?
Bob
Did you set the TreeView.SelectedNodeStyle
Bob
ASKER
I've implemented the code from:
http://blog.binaryocean.com/2006/01/19/SaveTreeViewNodesExpansionCollapseStateCSAndVB.aspx
It dosnt hightlight the TreeView.SelectedNodeStyle , The problem I'm having is that, I dont know where to palce the code in the CS file. Its way to complicating for me, do you think you can look into it for me Bob?
Thanks
http://blog.binaryocean.com/2006/01/19/SaveTreeViewNodesExpansionCollapseStateCSAndVB.aspx
It dosnt hightlight the TreeView.SelectedNodeStyle
Thanks
No, unfortunately I have deadlines to meet, and I don't have the time. I was hoping that this would be a simple solution, but it has turned out to be that.
Bob
Bob
ASKER
ok Bob
Thanks for helping out anyway
Mousemat24
Thanks for helping out anyway
Mousemat24
ASKER
Even though this problem never got sorted out, I'd like to give you the points TheLearnedOne for helping out, but I dont know what to accept?
Thanks
Thanks
Bob