473,396 Members | 1,767 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,396 software developers and data experts.

Dynamically Created Controls

Hi,

I have created a method that creates a link button dynamically and
places it within a place holder. The code I have creates the button,
but when it is clicked the button method is not fired. Below is the
code the creates the button:

LinkButton lb1 = new LinkButton();
lb1.ID = "lb1" + day.ToString( "ddMMMyyyy" );
lb1.Text = day.ToString( "dd" );
lb1.SkinID = "linkButtonSkin3";
lb1.CommandArgument = day.ToString( "ddMMMyyyy" );
lb1.Click += new EventHandler( EditDay );

A unique ID is given for every button.

I am unsing Visual Studio 2005 and Asp.net 2.0.

Any help on this would be much appreciated.

Thanks in advance.

Simon

Aug 31 '06 #1
3 1029
"accyboy1981" <ac*********@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
I have created a method that creates a link button dynamically and
places it within a place holder. The code I have creates the button,
but when it is clicked the button method is not fired. Below is the
code the creates the button:

LinkButton lb1 = new LinkButton();
lb1.ID = "lb1" + day.ToString( "ddMMMyyyy" );
lb1.Text = day.ToString( "dd" );
lb1.SkinID = "linkButtonSkin3";
lb1.CommandArgument = day.ToString( "ddMMMyyyy" );
lb1.Click += new EventHandler( EditDay );

A unique ID is given for every button.

I am unsing Visual Studio 2005 and Asp.net 2.0.

Any help on this would be much appreciated.
In which Page method are you creating the control? I'm betting you're not
creating it in Page_Init...
Aug 31 '06 #2
Hi,

Thanks for the response.

I've tried creating the buttons in the Page_Init, but the problem with
this is that I dont know the name as it will be dynamically choosen.

Basically what I am doing is creating a calendar for a year, and when a
user clicks a specific date if post-backs and runs a different method.
When it doen this the calendar is not drawn so this button will not
appear on the page. I am trying to pass the date that was clicked in
the commandargument so all I need is one method for the 365 days a user
can click. The problem I am finding is that because the button is not
drawn once it has been clicked it cannot be found.

Is there any way around this? Is it possible to have dynamic controls
this way on the same page?

Any help would be appreciated

Thanks

Simon

Sep 1 '06 #3
"accyboy1981" <ac*********@gmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
I've tried creating the buttons in the Page_Init, but the problem with
this is that I dont know the name as it will be dynamically choosen.
That's what ClientID is for... :-)
http://www.codeproject.com/aspnet/re...in_asp_net.asp
Sep 1 '06 #4

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

Similar topics

3
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
0
by: John Crowley | last post by:
I'm having an odd problem with viewstate and a dynamically created control inside a repeater template. Basically, I have a repeater setup like this in the aspx:
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am have facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web...
2
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
1
by: Marcus | last post by:
I have a problem maybe one of you could help me with. I've created a data entry screen with lots of dynamically-created client-side controls. I create HTML texboxes client-side by assigning a...
5
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...
9
by: Chris | last post by:
I am dynamically adding a user control to each row in a gridview. The reason I am doing it dynamically is the user control is different depending on certain data in the gridview. The gridview...
4
by: mohaaron | last post by:
I can think of a lot of reasons why this might need to be done but as far as I can tell it's not possible. I've been looking for a way to add HtmlTableRows to a table using a button click for a...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.