473,787 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating Event Handling with Dynamically Created Buttons - C#

1 New Member
I currently have a FlowLayoutPanel that creates buttons dynamically for each entry in a database:

for (int i = 0; i < int_num_users; i++)
{
Button b = new Button();
b.Text = str_user_names[i];
b.Size = new Size(150, 75);
Font boldfont = new Font("Times new roman", 16.0F, FontStyle.Bold) ;
b.Font = boldfont;
flowLayoutPanel 1.Controls.Add( b);
}

It's working fine, it creates one button for each user in my database. However, I need to be able to create an event for each button. The event will open up a new form and prompt the user to enter in their passcode. I know how to create a new event, but how can I pass the b.Text parameter into this event to validate the entered passcode with the passcode stored in the database?
Feb 5 '08 #1
1 2226
Plater
7,872 Recognized Expert Expert
Button click events already contain what you need.
They have the object sender attribute.
Cast that attribute as a Control (or even as a Button) and use the .Text property then.
Feb 5 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1049
by: Pravin | last post by:
Hi All, In my application it is required that I create multiple instances of a linkbutton. I am assigning ID's to each of these buttons depending upon the sequence that they are created i.e., ID for 1st button = Button1, for 2nd button Button2 and so on... When I click on any of these linkbuttons, that should get removed from the form and the next button in the sequence has it's ID changed to the deleted buttons ID. i.e., If Button2 is...
3
1933
by: Peter Vermilye | last post by:
How can I dynamically create buttons and wire them to an event handler? I have seen how I can add buttons to an event handler that are pre-created as part of the codebehind using AddHandler, but I can't use AddHandler with a button that is created locally, nor can I seem to create multiple button objects and add them to the page using a button object that exists outside the procedure I am using.... thus: Protected WithEvents...
9
2337
by: Sridhar | last post by:
Hi, I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control into the place holder. This is done dynamically based on the choice they selected. This user control has a datagrid in it that supports paging. When I click on the next or prev buttons of the datagrid in a user control it should display the next page...
9
14459
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it does not. The problem is that the webcontrols get created on the OnLoad event of the usercontrol and the event handlers are assigned at the same time. I have to click twice on the controls for the events to be raised, the first time nothing...
3
1114
by: Michael Dawson | last post by:
I am creating a list of items which need to be clickable on a web page, but I am unfamiliar with ASP event handling. I created the following test control: public class MyCustomControl : System.Web.UI.WebControls.WebControl { //--- public MyCustomControl() { // Init the class
5
12554
by: sam | last post by:
Hi all, I am dynamically creating a table rows and inerting radio buttons which are also dynamically created. Everything works fine in Firefox as expected. But I am not able to select radio buttons in IE. It does not even throw any errors. I have searched over the net but could not find anyhelp. Hope some experts here could help me. Here is part my code that dynamically generates the radio buttons, I cannot paste the entire code as it is...
7
3574
by: rsaffy | last post by:
I am having trouble with my dynamically created button's event handling. I read that the buttons need to be recreated on every trip to the server, but how exactly do you do that when the datagrid the button is added to is created at run time? here is code from my aspx page... ------------------------------------------------------------------------------------- <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">...
9
11932
by: lilOlMe | last post by:
Hi there! I have generated a GridView that looks something like: SportName| CompanyNameX |CompanyNameY |CompanyNameZ Hockey.....| Shipping------------ |Accounting-------- |Shipping------------ BaseBall...| Receiving-----------|Shipping------------|Accounting--------- Etc............| Accounting----------|Receiving---------- |Receiving----------- Where there are an unknown number of Company Names and an unknown number of Sport...
1
1449
by: successgac | last post by:
//I have the event declerations as follows down in a separate class file public event CommandEventHandler PageNumberClicked; //I have created link button dynamically using the following C# code which is also available in the same class HtmlTableCell htcPageNumber = new HtmlTableCell(); htcPageNumber.Attributes.Add("valign", "middle"); LinkButton lnkNewPageLink = new LinkButton(); ...
0
9497
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
10169
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
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
7517
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
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.