G
gxp
Unregistered / Unconfirmed
GUEST, unregistred user!
我做了个树型目录,想要获取选中的节点的名称.但我定义的TreeView_SelectedIndexChange()事件并没有被执行.求高手指教.代码如下:
private void TreeView_SelectedIndexChange(object sender, Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs e)
{
text.Value=TreeView.GetNodeFromIndex(TreeView.SelectedNodeIndex).Text;
}
,其中AutoPostBack属性社为False,如设为ture的话TreeView_SelectedIndexChange()就可以执行,我试过了的,但是刷新得让我感到痛苦。我把AutoPostBack属性社为False的时候。在body里添加 <body onload="initTree()">
然后在PageLoad里写:
string strTreeName = "TreeView1";
string strRef = Page.GetPostBackEventReference(TreeView1);
//
string strScript = "<script language=/"JavaScript/"> /n"
+ "<!-- /n"
+ "function initTree() { /n"
+"
"
+ strTreeName + ".onSelectedIndexChange = function() { /n"
+ "
if (event.oldTreeNodeIndex != event.newTreeNodeIndex) /n"
+ "this.queueEvent('onselectedindexchange', event.oldTreeNodeIndex + ',' + event.newTreeNodeIndex);
/n"
+ "window.setTimeout('"
+ strRef.Replace("'","//'" + "', 0, 'JavaScript');
/n"
+ "
} /n"
+ "
} /n"
+ "
--> /n"
+ "</script>"
;
Page.RegisterClientScriptBlock("InitTree",strScript );
TreeView_SelectedIndexChange()只会执行一次,就会报错,说缺少对象!
高手们,帮忙啊!在线等!!!急急急!!!!
private void TreeView_SelectedIndexChange(object sender, Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs e)
{
text.Value=TreeView.GetNodeFromIndex(TreeView.SelectedNodeIndex).Text;
}
,其中AutoPostBack属性社为False,如设为ture的话TreeView_SelectedIndexChange()就可以执行,我试过了的,但是刷新得让我感到痛苦。我把AutoPostBack属性社为False的时候。在body里添加 <body onload="initTree()">
然后在PageLoad里写:
string strTreeName = "TreeView1";
string strRef = Page.GetPostBackEventReference(TreeView1);
//
string strScript = "<script language=/"JavaScript/"> /n"
+ "<!-- /n"
+ "function initTree() { /n"
+"
"
+ strTreeName + ".onSelectedIndexChange = function() { /n"
+ "
if (event.oldTreeNodeIndex != event.newTreeNodeIndex) /n"
+ "this.queueEvent('onselectedindexchange', event.oldTreeNodeIndex + ',' + event.newTreeNodeIndex);
/n"
+ "window.setTimeout('"
+ strRef.Replace("'","//'" + "', 0, 'JavaScript');
/n"
+ "
} /n"
+ "
} /n"
+ "
--> /n"
+ "</script>"
;
Page.RegisterClientScriptBlock("InitTree",strScript );
TreeView_SelectedIndexChange()只会执行一次,就会报错,说缺少对象!
高手们,帮忙啊!在线等!!!急急急!!!!