VBForums >
.NET >
ASP.NET > How may I handle click-events for objects that I stored in a placeholder?
Click to See Complete Forum and Search --> : How may I handle click-events for objects that I stored in a placeholder?
fabianus
May 12th, 2005, 05:31 AM
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.
Footracer
May 12th, 2005, 08:17 AM
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.
fabianus
May 13th, 2005, 07:52 AM
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/default.asp?url=/workshop/webcontrols/webcontrols_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/webcontrols/overview/treeview.asp#Programming_with_TreeView
Thank you very much in advance.
Fabian
fabianus
May 16th, 2005, 12:22 AM
Finally I got it!
Thank you.
Fabian
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.