TreeView_SelectedIndexChange()事件为何不执行? ( 积分: 10 )

  • 主题发起人 主题发起人 gxp
  • 开始时间 开始时间
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=&quot;initTree()&quot;>
然后在PageLoad里写:
string strTreeName = &quot;TreeView1&quot;;
string strRef = Page.GetPostBackEventReference(TreeView1);
//
string strScript = &quot;<script language=/&quot;JavaScript/&quot;> /n&quot;
+ &quot;<!-- /n&quot;
+ &quot;function initTree() { /n&quot;
+&quot;
&quot;
+ strTreeName + &quot;.onSelectedIndexChange = function() { /n&quot;
+ &quot;
if (event.oldTreeNodeIndex != event.newTreeNodeIndex) /n&quot;
+ &quot;this.queueEvent('onselectedindexchange', event.oldTreeNodeIndex + ',' + event.newTreeNodeIndex);
/n&quot;
+ &quot;window.setTimeout('&quot;
+ strRef.Replace(&quot;'&quot;,&quot;//'&quot;) + &quot;', 0, 'JavaScript');
/n&quot;
+ &quot;
} /n&quot;
+ &quot;
} /n&quot;
+ &quot;
--> /n&quot;
+ &quot;</script>&quot;
;
Page.RegisterClientScriptBlock(&quot;InitTree&quot;,strScript );
TreeView_SelectedIndexChange()只会执行一次,就会报错,说缺少对象!
高手们,帮忙啊!在线等!!!急急急!!!!
 
我做了个树型目录,想要获取选中的节点的名称.但我定义的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=&quot;initTree()&quot;>
然后在PageLoad里写:
string strTreeName = &quot;TreeView1&quot;;
string strRef = Page.GetPostBackEventReference(TreeView1);
//
string strScript = &quot;<script language=/&quot;JavaScript/&quot;> /n&quot;
+ &quot;<!-- /n&quot;
+ &quot;function initTree() { /n&quot;
+&quot;
&quot;
+ strTreeName + &quot;.onSelectedIndexChange = function() { /n&quot;
+ &quot;
if (event.oldTreeNodeIndex != event.newTreeNodeIndex) /n&quot;
+ &quot;this.queueEvent('onselectedindexchange', event.oldTreeNodeIndex + ',' + event.newTreeNodeIndex);
/n&quot;
+ &quot;window.setTimeout('&quot;
+ strRef.Replace(&quot;'&quot;,&quot;//'&quot;) + &quot;', 0, 'JavaScript');
/n&quot;
+ &quot;
} /n&quot;
+ &quot;
} /n&quot;
+ &quot;
--> /n&quot;
+ &quot;</script>&quot;
;
Page.RegisterClientScriptBlock(&quot;InitTree&quot;,strScript );
TreeView_SelectedIndexChange()只会执行一次,就会报错,说缺少对象!
高手们,帮忙啊!在线等!!!急急急!!!!
 
怎么没有人理啊,自己顶一下!高手帮忙运行一下咯!javascript在哪里出错了,说缺少对象!!!我的QQ:36244374
 
后退
顶部