473,326 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Experts: dynamic control events???

Hi all.

In response to user selections, our app adds controls (buttons, image
buttons) dynamically to a page with Controls.Add(myNewButtonControl).

Now that we gotten on the page we want to make them do something for a
living: how do we dynamically create events that the controls respond to?

TEA for any pointers.

- Assaf

Nov 18 '05 #1
3 1140
Assaf hi,

You need to attach methods on your page to controls events. if you using
C# :
MyControl.Click += new EventHandler(FunctionNameWithDelegartionSign(;

VB:

AddHandlerMyControl.Click , AddressOf FunctionNameWithDelegartionSign

BUT! Event handler for dynamic control should be added before the page
finish to build controls. in the page life cycle the Load event is the
one that you can use.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2
Thanks a bunch Bin Song.

One of the articles you listed revealed the missing part of the puzzle: I
couldn't get the events for the dynamic control (which by the way is a
custom composite control) to fire. What was missing was impmenting the
System.Web.UI.INamingContainer interface on the control.

- Assaf

"Bin Song, MCP" <an*******@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
Hi,

If you know the object type and name, see this:
http://support.microsoft.com/default...b;en-us;317515
HOW TO: Dynamically Create Controls in ASP.NET with Visual Basic .NET
If Not,
http://support.microsoft.com/default...b;en-us;311321
HOW TO: Dynamically Add a Control Without Hardcoding the Control Type in Visual Basic .NET
Bin Song, MCP

Nov 18 '05 #3
Thanks for the pointer, Natty Guru.

I think I accidentally bypassed the problem by implementing the dynamically
added controls as custom composite controls. That way all the functionality
is baked into the composite control's inner controls (e.g., the button
control in the MyCustomCompositeControl control). I had to implement custom
composites for other reason, of course, not just to get around this problem.

- Assaf
"Natty Gur" <na***@dao2com.com> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Assaf hi,

You need to attach methods on your page to controls events. if you using
C# :
MyControl.Click += new EventHandler(FunctionNameWithDelegartionSign(;

VB:

AddHandlerMyControl.Click , AddressOf FunctionNameWithDelegartionSign

BUT! Event handler for dynamic control should be added before the page
finish to build controls. in the page life cycle the Load event is the
one that you can use.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: MikeY | last post by:
Hi Everyone, I am working in C#, windows forms.My question is this. All my button dynamic controls properties are present and accounted for except for the"FlatStyle" properties. I can't seem to...
6
by: Mark | last post by:
I have been working for quite some time on this issue which in theory should be quite simple. The problem is that the Cancel and Save events are not fired when their respective buttons are...
1
by: hybrid | last post by:
I have problems in understanding the behavior of the events triggered by dynamically created controls over a webform. Could you help me? In a webform, I have a static PlaceHolder PH containing...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
2
by: Michael Ramey | last post by:
Howdy, I think I have a good question! I'm creating a usercontrol, and within this usercontrol, I'm dynamically creating controls (imagebuttons to be exact), that the user can click on which...
0
by: Michael Ramey | last post by:
Hello, I'm trying to handle click events with button controls I've created dynamically. I've found two ways of dealing with them, neither of which I like, so I'm asking if anyone knows a better...
3
by: RSB | last post by:
Hi Every one Having tuff time creating web controls Dynamically. All i am trying to do is read a table and generate a list of ASP TEXT Box. So how do i create this Control dynamically and where...
13
by: Chris Thunell | last post by:
I have created several grids dynamically and have added them to different HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page...
5
by: mytestemailaccount | last post by:
Hi, Hope you can help. I am relatively new to all this but would appreciate the groups help. The scenario: I am c# and asp.net to create a web application. The web page contains a user...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.