Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Dynamic Control and Event handling

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DotNetDev - 12 Dec 2007 21:14 GMT
Hi,

I add some checkboxes to an <ASP.Table>

I want execute a function whenever one of the checkboxes is clicked.

How can I do that.

This is how I was trying...
TableRow aRow    = new TableRow();
CheckBox aBox    = new CheckBox();
aBox.ID        = "SomeID";
aBox.CheckedChanged += new EventHandler(aBox_CheckedChanged);
aBox.AutoPostBack = true;
TableCell aCell = new TableCell();
aCell.Controls.Add(aBox);
aRow.Cells.Add(aCell);
aTable.Rows.Add(aRow);

where aTable is a 'System.Web.UI.WebControls.Table'

Thnx for your help.
Scott Roberts - 12 Dec 2007 21:36 GMT
Works fine for me:

   protected void Page_Load(object sender, EventArgs e)
   {
       TableRow aRow = new TableRow();
       CheckBox aBox = new CheckBox();
       aBox.ID = "SomeID";
       aBox.CheckedChanged += new EventHandler(aBox_CheckedChanged);
       aBox.AutoPostBack = true;
       TableCell aCell = new TableCell();
       aCell.Controls.Add(aBox);
       aRow.Cells.Add(aCell);
       Table1.Rows.Add(aRow);
   }

   private void aBox_CheckedChanged(object sender, EventArgs e)
   {
       Console.WriteLine((sender as CheckBox).Checked.ToString());
   }

> I add some checkboxes to an <ASP.Table>
>
[quoted text clipped - 16 lines]
>
> Thnx for your help.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.