We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

BaseElement array

I am evaluating HtmlUI and trying to get a handle on how I should use it for my situation properly. I need to dynamically build an html document with a variable number of buttons. I have the document built and htmlui works great. I have a qustion on how to properly structure the events to handle the button clicks. Currently I am ... Dim policyBtn() As BaseElement policyBtn(polCnt) = htmlelements(polName) I am currently creating a seperate event handler for each button in the policyBtn array and it works great. However I would like to create a single event handler and in the Click event determine which button was clicked either by index or element name. Is there a straightforward way of doing this? Thanks

1 Reply

DJ Davis Jebaraj Syncfusion Team March 15, 2005 10:55 AM

Hi Mike, The HTMLUIControl supports bubbling events. If some element raises an event (for instance Click), the parent elements also raise the same event if they support it. This allows us to handle the Click event of a top level Element and get the BubblingEventArgs using the static HTMLUIControl.GetBubblingEventArgs( EventArgs e) method. The RootSender of the BubblingEventArgs is the Button that was clicked: private void body_OnClick(object sender, EventArgs e) { BubblingEventArgs bargs = HTMLUIControl.GetBublingEventArgs(e); BaseElement elem = bargs.RootSender as BaseElement; if( elem != null && elem is INPUTElementImpl) { if(elem.ID == "Button1") { Console.WriteLine("Button 1 clicked"); } else if(elem.ID == "Button2") { Console.WriteLine("Button 2 clicked"); } else if(elem.ID == "Button3") { Console.WriteLine("Button 3 clicked"); } else if(elem.ID == "Button4") { Console.WriteLine("Button 4 clicked"); } } } Please refer to the sample linked to below: http://www.syncfusion.com/support/user/uploads/htmluibubblingevents.zip Thanks, Davis

Loader.
Live Chat Icon For mobile
Up arrow icon