请教: TreeView 中节点的NavigateURL 属性设为javascript:ShowContent(n) 后节点不能被选中的问题

外星人oo 2005-08-25 02:47:32
TreeView 代码

<iewc:TreeView id="TreeView1" runat="server" TreeNodeXsltSrc="TreeNodes.xslt" TreeNodeSrc="Book.xml">
</iewc:TreeView>
...全文
163 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wzs_wzs123 2005-08-31
  • 打赏
  • 举报
回复
兄弟我找到解决方法了在treeview.htc文件中
把函数function doNodeClick(el)
中的
function doNodeClick(el)
{
if (g_bInteractive == false)
return;

g_nodeClicked = el;

// The element, which is in a content node outside of the document, is outside the event hierarchy.
// Fire the event ourselves, rather than relying on bubbling.
event.cancelBubble = true;
el.fireEvent("onclick"); // Execute our onclick handler
element.fireEvent("onclick", event); // Execute the tree's onclick handler

if (getNodeAttribute(el, "NavigateUrl") != null)
{
var target = getNodeAttribute(el, "Target");
// if (target == null || target.toLowerCase() == "_self")
// return false;
}

selectNode(el);
return true;
}
这段程序品屏蔽掉
// if (target == null || target.toLowerCase() == "_self")
// return false;
wzs_wzs123 2005-08-31
  • 打赏
  • 举报
回复
外星人oo 2005-08-25
  • 打赏
  • 举报
回复
请高手指点一二
外星人oo 2005-08-25
  • 打赏
  • 举报
回复
TreeNodes.xslt

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
<xsl:template match="/">
<TREENODES>
<xsl:for-each select="Book/BookTitle">
<xsl:element name="TreeNode">
<xsl:attribute name="Text" ><xsl:value-of select="@Title"/></xsl:attribute>
<xsl:attribute name="Expanded" >True</xsl:attribute>
<xsl:attribute name="Type" >BookTitle</xsl:attribute>
<xsl:for-each select="Chapter">
<xsl:element name="TreeNode">

<xsl:attribute name="Text" ><xsl:value-of select="@Title"/></xsl:attribute>
<xsl:attribute name="NavigateURL" >javascript:ShowContent('<xsl:value-of select="@NodeID"/>')</xsl:attribute>
<xsl:attribute name="Type" >Chapter</xsl:attribute>
<xsl:for-each select="Section">
<xsl:element name="TreeNode">
<xsl:attribute name="Text" ><xsl:value-of select="@Title"/></xsl:attribute>
<xsl:attribute name="NavigateURL" >javascript:ShowContent('<xsl:value-of select="@NodeID"/>')</xsl:attribute>
<xsl:attribute name="Type" >Section</xsl:attribute>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:for-each>

</xsl:element>
</xsl:for-each>
</TREENODES>
</xsl:template>
</xsl:stylesheet>
外星人oo 2005-08-25
  • 打赏
  • 举报
回复
Book.xml


<?xml version="1.0" ?>
<Book>

<BookTitle Title = "网站项目" >
<Chapter NodeID="1" Title="前言"><![CDATA[1章的内容]]>
</Chapter>
<Chapter NodeID="2" Title="概述">2章的内容
</Chapter>
<Chapter NodeID="" Title="生命周期">
<Section NodeID="31" Title = "项目定义" >31节的内容</Section>
<Section NodeID="32" Title = "项目评估" >32节的内容</Section>
<Section NodeID="33" Title = "项目方案" >33节的内容</Section>
<Section NodeID="34" Title = "项目分析" >34节的内容</Section>
<Section NodeID="35" Title = "项目资源" >35节的内容</Section>
<Section NodeID="36" Title = "项目控制计划" >36节的内容</Section>
</Chapter>
<Chapter NodeID="" Title="团队管理">
<Section NodeID="41" Title = "团队组成" >41节的内容</Section>
<Section NodeID="42" Title = "管理方法" >42节的内容</Section>
</Chapter>
</BookTitle>
</Book>

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧