我的代码是:
<asp:TreeView ID="TreeViewCategories" runat="server" ExpandDepth="0" Style="min-height: 200px;
max-height: 500px;" LineImagesFolder="~/TreeLineImages" NodeIndent="0" LeafNodeStyle-CssClass="LeafNodesStyle"
CssClass="TreeView" NodeStyle-CssClass="NodeStyle" ParentNodeStyle-CssClass="ParentNodeStyle"
RootNodeStyle-CssClass="RootNodeStyle" SelectedNodeStyle-CssClass="SelectedNodeStyle"
LeafNodeStyle-Width="100%" NodeStyle-Width="100%" ParentNodeStyle-Width="100%"
RootNodeStyle-Width="100%" Font-Size="12pt">
<Nodes>
<asp:TreeNode Text="All Items" SelectAction="Expand" PopulateOnDemand="True" Value="All Items" />
</Nodes>
</asp:TreeView>
css
.TreeView
{
border-bottom:1px dotted #B2B2B2 !important;
}
.TreeView div
{
margin-left:5px;
}
.TreeView table
{
border-top:1px dotted #B2B2B2 !important;
}
.TreeView div table
{
border-bottom:none !important;
border-top:none !important;
}
.TreeView table td
{
padding:2px 0;
}
.LeafNodesStyle
{
}
.RootNodeStyle
{
}
/* ALL ELEMENTS */
.NodeStyle
{
}
.ParentNodeStyle
{
/*background:yellow;*/
}
.SelectedNodeStyle { font-weight: bold; color:#6799D1; display:block; padding:2px 0 2px 3px; }
所以我看到(使用firebug)我选择的节点出现了 Visited style 、 node style 、 leaf style 但没有 Selected node style :(
例如,如何修复此 HTML/CSS/ASP 以使所选节点变为粗体和蓝色?
谢谢。
添加:添加节点如下:
foreach(c : Category in rootCategories)
{
mutable newNode : TreeNode = TreeNode(c.Title, c.Id);
newNode.SelectAction = TreeNodeSelectAction.SelectExpand;
newNode.NavigateUrl = "Items.aspx?catId=" + c.Id.ToString() + "&lvl=0";
解决了...
categoryId : string = Request.QueryString["catId"];
n : TreeNode = findNode(categoryId, TreeViewCategories.Nodes, lvl);
n.Selected = true;
The 选择动作属性上的asp:树节点是 展开 将其更改为选择展开.
这可确保存在回发并且重新绘制树控件以应用您在树视图上设置的选定节点样式
<asp:TreeView ID="TreeViewCategories" runat="server" ExpandDepth="0" Style="min-height: 200px;
max-height: 500px;" LineImagesFolder="~/TreeLineImages" NodeIndent="0" LeafNodeStyle-CssClass="LeafNodesStyle"
CssClass="TreeView" NodeStyle-CssClass="NodeStyle" ParentNodeStyle-CssClass="ParentNodeStyle"
RootNodeStyle-CssClass="RootNodeStyle" SelectedNodeStyle-CssClass="SelectedNodeStyle"
LeafNodeStyle-Width="100%" NodeStyle-Width="100%" ParentNodeStyle-Width="100%"
RootNodeStyle-Width="100%" Font-Size="12pt">
<Nodes>
<asp:TreeNode Text="All Items" SelectAction="SelectExpand" Value="All Items">
<asp:TreeNode Text="All Items" SelectAction="SelectExpand" Value="All Items" />
<asp:TreeNode Text="All Items" SelectAction="SelectExpand" Value="All Items" />
<asp:TreeNode Text="All Items" SelectAction="SelectExpand" Value="All Items" />
</asp:TreeNode>
</Nodes>
</asp:TreeView>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)