TreeView 客户端响应点击的方法
- 服务器端
protected void Page_Load(object sender, EventArgs e)
{
this.TreeView1.Attributes.Add("OnClick", "ClickNode()");
}
或直接在页面设计中设置:
<asp:TreeView ID="TreeView1" OnClick="ClickNode()" runat="server">
</asp:TreeView>
2. 客户端
<script type="text/javascript">
function ClickNode()
{
var Obj=event.srcElement;
var s = Obj.toString();
var lastIndex = s.lastIndexOf('\\');
lastIndex = lastIndex + 1;
if (lastIndex == 0)
{
lastIndex = s.indexOf("','s") + 4;
}
var nodeValue = s.substring(lastIndex);
var nodeText = Obj.innerText;
// if(Obj.tagName == "A" || Obj.tagName== "a")
// {
// alert(Obj.innerText);
// }
} </script>