Click here to Skip to main content
15,912,756 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: How to test if an object property exists in JS Pin
Konstantin Vasserman23-Jan-02 15:44
Konstantin Vasserman23-Jan-02 15:44 
AnswerRe: How to test if an object property exists in JS Pin
Torsten Mauz11-Mar-02 5:19
Torsten Mauz11-Mar-02 5:19 
GeneralVisual Inheritance in ASP.NET Pin
22-Jan-02 13:44
suss22-Jan-02 13:44 
GeneralRe: Visual Inheritance in ASP.NET Pin
Konstantin Vasserman23-Jan-02 15:31
Konstantin Vasserman23-Jan-02 15:31 
GeneralRe: Visual Inheritance in ASP.NET Pin
24-Jan-02 5:22
suss24-Jan-02 5:22 
GeneralRe: Visual Inheritance in ASP.NET Pin
Konstantin Vasserman24-Jan-02 5:49
Konstantin Vasserman24-Jan-02 5:49 
GeneralDynamic control creation and event handling Pin
omkamal22-Jan-02 11:41
omkamal22-Jan-02 11:41 
GeneralRe: Dynamic control creation and event handling Pin
Konstantin Vasserman24-Jan-02 5:45
Konstantin Vasserman24-Jan-02 5:45 
To handle events of dynamically added controls you need to create a function that will handle event like this:

private void myCtrl_Click(Object Source, EventArgs e)
{
    ...
}


then you need to add your control as follow:

TableCell tc = new TableCell();
CheckBox chkBox = new CheckBox();
chkBox.ID = "chkBox"; // you need this to be able to refer to it later
chkBox.CheckedChanged += new System.EventHandler(this.myCtrl_Click);
tc.Controls.Add(chkBox);


Events will one fire if your control is added inside of your form. If it will happen to be outside of the form object event will not fire. That means that your table cell should be added to your form not just to the page. In order to add controls to the form you need to give your form an ID

<form id="frmMain" ... >


then you need to add a field to your class that corresponds to the form:

protected HtmlForm frmMain;


Now when you are adding your table to the page you need to add it to the form instead:

frmMain.Controls.Add(myTable);


To refer to your chkBox you can do this anywhere in your code:

CheckBox chkBox = (CheckBox)FindControl("chkBox");
if( chkBox != null )
{
    // Do something
    chkBox.Checked = true;
}


I hope this helps.
GeneralRe: Dynamic control creation and event handling Pin
omkamal24-Jan-02 16:49
omkamal24-Jan-02 16:49 
GeneralRe: Dynamic control creation and event handling Pin
Konstantin Vasserman25-Jan-02 4:10
Konstantin Vasserman25-Jan-02 4:10 
GeneralRe: Dynamic control creation and event handling Pin
omkamal25-Jan-02 4:24
omkamal25-Jan-02 4:24 
GeneralRe: Dynamic control creation and event handling Pin
Konstantin Vasserman25-Jan-02 5:06
Konstantin Vasserman25-Jan-02 5:06 
GeneralRe: Dynamic control creation and event handling Pin
omkamal25-Jan-02 7:47
omkamal25-Jan-02 7:47 
GeneralRe: Dynamic control creation and event handling Pin
Konstantin Vasserman25-Jan-02 10:00
Konstantin Vasserman25-Jan-02 10:00 
GeneralRe: Dynamic control creation and event handling Pin
omkamal28-Jan-02 4:45
omkamal28-Jan-02 4:45 
GeneralRe: Dynamic control creation and event handling Pin
Konstantin Vasserman28-Jan-02 4:54
Konstantin Vasserman28-Jan-02 4:54 
GeneralRe: Dynamic control creation and event handling Pin
omkamal28-Jan-02 4:56
omkamal28-Jan-02 4:56 
GeneralRe: Dynamic control creation and event handling Pin
Konstantin Vasserman28-Jan-02 10:04
Konstantin Vasserman28-Jan-02 10:04 
GeneralPassing Variables Between Pages in ASP.NET Pin
21-Jan-02 21:48
suss21-Jan-02 21:48 
GeneralRe: Passing Variables Between Pages in ASP.NET Pin
Konstantin Vasserman23-Jan-02 15:08
Konstantin Vasserman23-Jan-02 15:08 
General.NET Positioning controls programatically Pin
Eivind21-Jan-02 4:15
Eivind21-Jan-02 4:15 
GeneralRe: .NET Positioning controls programatically Pin
Konstantin Vasserman21-Jan-02 5:04
Konstantin Vasserman21-Jan-02 5:04 
GeneralRe: .NET Positioning controls programatically Pin
Eivind21-Jan-02 11:39
Eivind21-Jan-02 11:39 
GeneralRe: .NET Positioning controls programatically Pin
Konstantin Vasserman21-Jan-02 11:46
Konstantin Vasserman21-Jan-02 11:46 
GeneralRe: .NET Positioning controls programatically Pin
Eivind21-Jan-02 12:33
Eivind21-Jan-02 12:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.