473,663 Members | 2,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Events for Dynamically created controls

Bob
I have a requirement to show a label and x number of buttons in all of the
pages.
So i decided to write a Base Page class and added code for dynamically
adding the label and buttons. For the buttons i have added the handlers.
Finally added the label and buttons to a place holder.

When page is rendered i am able to see the label and buttons. but when i
click the buttons events are not firing. i found two problems.

First one is when i click the buttons handlers are not firing. so i kept the
buttons in the session and added them back in the page_load event. by doing i
am able to go inside my handler function. In my handler function I am able to
fetch the information from the page, but not able to set any properties of
other controls. Like disabling a control etc.

Second one is when i write Response.write( "test"), it is saying context
does't have Response object.

I think i must be doing some thing wrong.Can someone help me with the above
Nov 18 '05 #1
1 1630
"Bob" wrote:
I have a requirement to show a label and x number of buttons in all of the
pages.
So i decided to write a Base Page class and added code for dynamically
adding the label and buttons. For the buttons i have added the handlers.
Finally added the label and buttons to a place holder.

When page is rendered i am able to see the label and buttons. but when i
click the buttons events are not firing. i found two problems.

First one is when i click the buttons handlers are not firing. so i kept the
buttons in the session and added them back in the page_load event. by doing i
am able to go inside my handler function. In my handler function I am able to
fetch the information from the page, but not able to set any properties of
other controls. Like disabling a control etc.

Second one is when i write Response.write( "test"), it is saying context
does't have Response object.

I think i must be doing some thing wrong.Can someone help me with the above


I'm sorry I don't know the answer to your question. Rather, I have almost
the exact same problem as the first one you mentioned but I don't think I can
solve my problem the same way. I am working within a method in a class in a
library that is called from who knows what other pages. So, how do I get the
events to work?
Nov 18 '05 #2

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

Similar topics

3
2424
by: Kenton Smeltzer | last post by:
Hello All, I am having a problem with events and the addition of controls on a page I am developing. First let me tell you what I have tried and then maybe someone can see something I missed. First I tried adding the controls and the event handlers for my control in the Initialize Components method of my page in the hopes that it would fire the event before the
1
1998
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 a table of controls, dynamically generated. Among these, a linkbutton (LinkBtn) to which have attached a click handler method, LinkBtn_Click(...) . Generally it works fine, but if in the LinkBtn_Click(...) code I try to access a webform control,...
4
2552
by: blue | last post by:
I have a drop-down list, a radio button list and a submit button. I'm adding these controls to a table and I'm adding the table to a Placeholder. I'm adding it to the Placeholder because I don't know exactly where the table will be located on the page until runtime. Before the form control table is added to the Placeholder, I'm adding a whole bunch of tables to the Placeholder. This is a flowchart program and I have multiple action boxes...
1
8156
by: Earl Teigrob | last post by:
PROBLEM: When a user control is loaded into a PlaceHolder control more than once, the events do not fire on the first click of a control on the dynamically loaded user control. In other words, the first time the control is dynamically loaded, everything works fine. After that, if the control is loaded again from the page button event handler, the user controls events fail to fire on the first click NOTE: I (believe I) am rebuilding all...
7
1306
by: bredal Jensen | last post by:
Hello, I have populated a web form with dynamically created radiobuttons in a table. I wnat some of the radio buttons to fire events when their ..CheckChanged property has changed. I understand and was told this can be done with events and delegates. But my code would not compile. Here is what i did.
5
1709
by: karthick raja | last post by:
Am experiencing a problem intercepting the events from controls added dynamically to a Placeholder control at runtime. Is there any way that I can write an event handler on the page which will be pick up the events raised by the added controls dynamically. I cannot use 'WithEvents' and 'Handles' because this requires that the controls be declared on the page and they aren't (they are created in the external class) I did think of using...
6
2851
by: hlubocky | last post by:
I thought I had a good grasp of the problem related to dynamically creating controls, but it appears that as my application grew in complexity, the problem has resurfaced. As I understand it, in order for a dynamically created control to persist its state, it needs to be created and loaded into the page control hierarchy before the viewstate is loaded. The proposed solution, and that which I have been using, has been to create all of...
3
8520
by: Mark | last post by:
Assume you want to dynamically add one to many link button controls to a web page dynamically at run time. Each link button needs to post back and execute code. As the link buttons are created at run time and the number may vary, we can't statically tie to the event to a control. I'm assuming I need to dynamically add event handlers at run time, and that one method could act as the event handler, with unique event args being created for...
5
6755
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created link buttons to stay wired up to their click events. I have what is basically a simply survey question generation page. The page first displays a few static fields and a dropdownlist of various options for the user to select. When the user...
2
1644
by: Nathan Sokalski | last post by:
I have LinkButtons that are dynamically created in one of the PostBack events. They must be created in the PostBack event because one of the variables required to determine which ones to create comes from the event arguments. Because the LinkButtons are not created in the Init event, they will not exist when I click them to perform a postback. How do I handle the events for these LinkButtons? I appreciate any help you can give. Thanks. --...
0
8436
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8858
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7371
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5657
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.