How may I handle click-events for objects that I stored in a placeholder?
How may I handle click-events for objects that I stored in a placeholder?
For example a button or a treeview? I would like to run a code once the user clicks on the object.
Thank you very much for any advice.
Re: How may I handle click-events for objects that I stored in a placeholder?
Firstly there is no native TreeView in ASP.NET only in .NET WinForms. In asp.net 2.0 there will be a native TreeView. :)
So you have to make your own treeview or get some component.
There is no difference on events on buttons and so on from when they are placed in placeholders. The event is on the object itself. Like:
PlaceHolder1 = new PlaceHolder();
System.Web.UI.WebControls.Button btn = new System.Web.UI.WebControls.Button();
btn.Text = "Test";
btn.Click += new EventHandler(btn_Click);
PlaceHolder1.Controls.Add(btn);
And the you have the eventhandling code in the corresponding btnClick method:
protected void btn_Click (object sender, System.EventArgs e)
{
//some eventhandling. This code will run when clicked
}
Hope it helps.
Re: How may I handle click-events for objects that I stored in a placeholder?
Hi Footracer,
Thank you very much for your explanation that gave me some very interesting material.
I tried different things, but I couldn't manage the following:
I have a treeview object (from Microsoft web controls)
Info here:
http://msdn.microsoft.com/library/de...rols_entry.asp
They explain how make an event handler when clicking on a node, but only for C# and I tried everything to put it into VB, but my knowledge does not go fare enough for that. Do you have an idea how to do?
http://msdn.microsoft.com/workshop/w..._with_TreeView
Thank you very much in advance.
Fabian
Re: How may I handle click-events for objects that I stored in a placeholder?
Finally I got it!
Thank you.
Fabian