日期:2014-05-16  浏览次数:20435 次

请教,如何用javascript获取treeview中TreeNode.Value的值

我是用VS2005开发平台的,问题如下:

我页面上左边是一个treeview控件,右边是一个iframe控件,现在我想在点击某子节点时,在不刷新页面的情况下,把TreeNode.Value(连接网页地址url)值取出来,传给iframe控件中属性scr,并把网页显示在iframe中.

最好给个例子,谢谢!

------解决方案--------------------
<asp:TreeView ID= "tvList " runat= "server " ImageSet= "XPFileExplorer " Width= "100% " ShowLines= "True "
OnSelectedNodeChanged= "tvList_SelectedNodeChanged " ExpandDepth= "1 " onclick= "tree_onclick(); ">
<Nodes>
<asp:TreeNode Text= "全部申请单({0}) " Value= "-1 " NavigateUrl= "javascript:void(0); ">
<asp:TreeNode Text= "已发送({0}) " Value= "1 " SelectAction= "Expand " ToolTip= "1 "> </asp:TreeNode>
<asp:TreeNode Text= "已审核({0}) " Value= "2 " SelectAction= "Expand " ToolTip= "2 "> </asp:TreeNode>
<asp:TreeNode Text= "已完成({0}) " Value= "3 " SelectAction= "Expand " ToolTip= "3 "> </asp:TreeNode>
<asp:TreeNode Text= "已撤单({0}) " Value= "4 " SelectAction= "Expand " ToolTip= "4 "> </asp:TreeNode>
</asp:TreeNode>
</Nodes>
<SelectedNodeStyle Font-Bold= "True " />
</asp:TreeView>

js

function tree_onclick()
{

if(window.event.srcElement.href.indexOf( 'ToggleNode ') > 0)
{
if(hisID != window.event.srcElement.id)
{
hisID = window.event.srcElement.id;
sCurState = $get(window.event.srcElement.id).title;
$get( 'ifrList ').src= "myPage.aspx?id= "+sCurState;
}

}

}