Reputation: 87
I'd like to click a node in my ASP.NET TreeView and make visible=false;
. How do I do that in JavaScript?
Upvotes: 5
Views: 1791
Reputation: 52241
You need to set a NagivateUrl equal to a Javascript function in the TreeView node to hide the button.
<asp:TreeView ID="TreeView1" runat="server" >
<Nodes>
<asp:TreeNode Text="" Value="" NavigateUrl="javascript:HideButton();"></asp:TreeNode>
</Nodes>
</asp:TreeView>
<script type="text/javascript" language="javascript">
function HideButton() {
document.getElementById('<%=Button1.ClientID %>').style.visibility = "hidden";
}
</script>
Upvotes: 2
Reputation: 14781
If you are asking about calling JavaScript functions from codebehind, use Page.ClientScript.RegisterStartupScript .
Upvotes: 0
Reputation: 59660
Try
document.getElementById("buttonId").style.visibility = "hidden";
or
document.getElementById("buttonId").style.display = "none";
Upvotes: 0