vasagam
vasagam

Reputation: 87

How do I make an ASP.NET TreeView not visible using JavaScript?

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

Answers (3)

Muhammad Akhtar
Muhammad Akhtar

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

Akram Shahda
Akram Shahda

Reputation: 14781

If you are asking about calling JavaScript functions from codebehind, use Page.ClientScript.RegisterStartupScript .

Upvotes: 0

Harry Joy
Harry Joy

Reputation: 59660

Try

document.getElementById("buttonId").style.visibility = "hidden";

or

document.getElementById("buttonId").style.display = "none";

Upvotes: 0

Related Questions