Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call a javascript inside SelectedNodeChanged event handler in c#

I have my treenode populated with data from database.The treeview code is as follows:

<asp:TreeView ID="mytv" runat="server" ImageSet="Arrows" 
        ondatabinding="Page_Load" onselectednodechanged="mytv_SelectedNodeChanged">

And the code-behind for this is as follows:

protected void mytv_SelectedNodeChanged(object sender, EventArgs e)
{
  // how to call java-script function from here.
}

What I am trying to achieve is to display the content of div as per the tree-node clicked using JavaScript.

Or is there any other way to display the content from database or from div on clicking the treeview node.

like image 320
user35 Avatar asked Dec 12 '25 10:12

user35


1 Answers

Use this one inside the method:

ScriptManager.RegisterStartupScript(this, this.GetType(), 
                                    "anyName", "alert('test');", true);
like image 149
Ali Avatar answered Dec 13 '25 22:12

Ali