1
以下.NET 4.0代碼在IE9,Chrome 20和Opera 12中完美運行,但在Firefox 13中表現不佳。所有瀏覽器均爲默認安裝,不含插件。適用於除Firefox以外的所有瀏覽器的ASP.NET TreeView代碼
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"><title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TreeView ID="Treeview1" Runat="server"
onclick="javascript:postBackByObject()"
ontreenodecheckchanged="Treeview1_TreeNodeCheckChanged"
ShowCheckBoxes="All" >
<Nodes>
<asp:TreeNode Value="Child1" Expanded="True" Text="1">
<asp:TreeNode Value="Grandchild1" Text="A" />
<asp:TreeNode Value="Grandchild2" Text="B" />
</asp:TreeNode>
<asp:TreeNode Value="Child2" Text="2" />
<asp:TreeNode Value="Child3" Expanded="True" Text="3">
<asp:TreeNode Value="Grandchild1" Text="A" />
</asp:TreeNode>
</Nodes>
</asp:TreeView>
<asp:TextBox ID="TextBox1" runat="server" Height="156px" TextMode="MultiLine"
Width="295px"></asp:TextBox>
</div>
</form>
</body>
<script language="javascript" type="text/javascript">
function postBackByObject() {
var o = window.event.srcElement;
if (o.tagName == "INPUT" && o.type == "checkbox") {
__doPostBack("", "");
}
}
</script>
</html>
我試圖趕上樹節點複選框事件背後下面的代碼:
protected void Treeview1_TreeNodeCheckChanged(object sender, TreeNodeEventArgs e)
{
TextBox1.Text += e.Node.Text;
}
這是很煩人的 - 任何解決方案是值得歡迎的!
非常感謝添:現在的代碼工作完全在四大瀏覽器。大! – jacques 2012-07-16 06:50:15
使用此更新面板後無法使用。 – SANDEEP 2018-03-08 09:50:46