I create the checkboxes dynamically on my webform (aspx). after I create
them, when I check any of the checkboxes, nothing happens. Here is my code
...
ArrayList LayerNameList1 = LayerNameList;
CheckBox[] checkBoxArray;
int BoxCount = 0;
HtmlTableRow newRow;
HtmlTableCell FieldCell;
System.Web.UI.H tmlControls.Htm lTable ContainerTable = new HtmlTable();
checkBoxArray = new CheckBox[250];
foreach(string item in LayerNameList1)
{
newRow = new HtmlTableRow();
FieldCell = new HtmlTableCell() ;
FieldCell.Style .Add("font-family", "Arial");
FieldCell.Style .Add("font-size", "smaller");
checkBoxArray[BoxCount] = new CheckBox();
checkBoxArray[BoxCount].ID = Convert.ToStrin g(BoxCount);
checkBoxArray[BoxCount].Text = item;
checkBoxArray[BoxCount].CheckedChanged += new
System.EventHan dler(checkBox_C heckedChanged);
FieldCell.Contr ols.Add(checkBo xArray[BoxCount]);
newRow.Controls .Add(FieldCell) ;
ContainerTable. Controls.Add(ne wRow);
BoxCount++;
}
this.placeHolde r.Controls.Add( ContainerTable) ;
}
public void checkBox_Checke dChanged(object sender, System.EventArg s e)
{
CheckBox cb = (CheckBox) sender;
if (cb.Checked)
{ testdel.Text = "1"; }
else
{ testdel.Text = "2";
}
}
Any suggestions?
Regards
Praveen 10 4584
Hi Steven,
I think you should set AutoPostBack="T rue".
Jie
"Steven" wrote: I create the checkboxes dynamically on my webform (aspx). after I create them, when I check any of the checkboxes, nothing happens. Here is my code ...
ArrayList LayerNameList1 = LayerNameList;
CheckBox[] checkBoxArray; int BoxCount = 0; HtmlTableRow newRow; HtmlTableCell FieldCell;
System.Web.UI.H tmlControls.Htm lTable ContainerTable = new HtmlTable(); checkBoxArray = new CheckBox[250]; foreach(string item in LayerNameList1) { newRow = new HtmlTableRow(); FieldCell = new HtmlTableCell() ; FieldCell.Style .Add("font-family", "Arial"); FieldCell.Style .Add("font-size", "smaller"); checkBoxArray[BoxCount] = new CheckBox(); checkBoxArray[BoxCount].ID = Convert.ToStrin g(BoxCount); checkBoxArray[BoxCount].Text = item;
checkBoxArray[BoxCount].CheckedChanged += new System.EventHan dler(checkBox_C heckedChanged);
FieldCell.Contr ols.Add(checkBo xArray[BoxCount]); newRow.Controls .Add(FieldCell) ; ContainerTable. Controls.Add(ne wRow); BoxCount++; } this.placeHolde r.Controls.Add( ContainerTable) ; }
public void checkBox_Checke dChanged(object sender, System.EventArg s e) { CheckBox cb = (CheckBox) sender;
if (cb.Checked) { testdel.Text = "1"; } else { testdel.Text = "2"; } }
Any suggestions?
Regards Praveen
Hello Peng,
Could you please tell me, where should I set AutoPostBack="T rue" in the
below code. I tried in checkBox_Checke dChanged function. But seems I'm
missing something.
Regards
Steven
"Peng Jie" <Pe*****@discus sions.microsoft .com> wrote in message
news:2A******** *************** ***********@mic rosoft.com... Hi Steven,
I think you should set AutoPostBack="T rue".
Jie
"Steven" wrote:
I create the checkboxes dynamically on my webform (aspx). after I create them, when I check any of the checkboxes, nothing happens. Here is my code ...
ArrayList LayerNameList1 = LayerNameList;
CheckBox[] checkBoxArray; int BoxCount = 0; HtmlTableRow newRow; HtmlTableCell FieldCell;
System.Web.UI.H tmlControls.Htm lTable ContainerTable = new HtmlTable(); checkBoxArray = new CheckBox[250]; foreach(string item in LayerNameList1) { newRow = new HtmlTableRow(); FieldCell = new HtmlTableCell() ; FieldCell.Style .Add("font-family", "Arial"); FieldCell.Style .Add("font-size", "smaller"); checkBoxArray[BoxCount] = new CheckBox(); checkBoxArray[BoxCount].ID = Convert.ToStrin g(BoxCount); checkBoxArray[BoxCount].Text = item;
checkBoxArray[BoxCount].CheckedChanged += new System.EventHan dler(checkBox_C heckedChanged);
FieldCell.Contr ols.Add(checkBo xArray[BoxCount]); newRow.Controls .Add(FieldCell) ; ContainerTable. Controls.Add(ne wRow); BoxCount++; } this.placeHolde r.Controls.Add( ContainerTable) ; }
public void checkBox_Checke dChanged(object sender, System.EventArg s e) { CheckBox cb = (CheckBox) sender;
if (cb.Checked) { testdel.Text = "1"; } else { testdel.Text = "2"; } }
Any suggestions?
Regards Praveen
What I mean is you can add
checkBoxArray[BoxCount].AutoPostBack = true;
into your foreach statement.
Then you can fire server side event and call CheckedChanged function.
"Steven" wrote: Hello Peng,
Could you please tell me, where should I set AutoPostBack="T rue" in the below code. I tried in checkBox_Checke dChanged function. But seems I'm missing something.
Regards Steven
"Peng Jie" <Pe*****@discus sions.microsoft .com> wrote in message news:2A******** *************** ***********@mic rosoft.com... Hi Steven,
I think you should set AutoPostBack="T rue".
Jie
"Steven" wrote:
I create the checkboxes dynamically on my webform (aspx). after I create them, when I check any of the checkboxes, nothing happens. Here is my code ...
ArrayList LayerNameList1 = LayerNameList;
CheckBox[] checkBoxArray; int BoxCount = 0; HtmlTableRow newRow; HtmlTableCell FieldCell;
System.Web.UI.H tmlControls.Htm lTable ContainerTable = new HtmlTable(); checkBoxArray = new CheckBox[250]; foreach(string item in LayerNameList1) { newRow = new HtmlTableRow(); FieldCell = new HtmlTableCell() ; FieldCell.Style .Add("font-family", "Arial"); FieldCell.Style .Add("font-size", "smaller"); checkBoxArray[BoxCount] = new CheckBox(); checkBoxArray[BoxCount].ID = Convert.ToStrin g(BoxCount); checkBoxArray[BoxCount].Text = item;
checkBoxArray[BoxCount].CheckedChanged += new System.EventHan dler(checkBox_C heckedChanged);
FieldCell.Contr ols.Add(checkBo xArray[BoxCount]); newRow.Controls .Add(FieldCell) ; ContainerTable. Controls.Add(ne wRow); BoxCount++; } this.placeHolde r.Controls.Add( ContainerTable) ; }
public void checkBox_Checke dChanged(object sender, System.EventArg s e) { CheckBox cb = (CheckBox) sender;
if (cb.Checked) { testdel.Text = "1"; } else { testdel.Text = "2"; } }
Any suggestions?
Regards Praveen
Hello Peng,
I tried this ..
checkBoxArray[BoxCount].AutoPostBack = true;
checkBoxArray[BoxCount].CheckedChanged += new
System.EventHan dler(checkBox_C heckedChanged11 );
but some how when I check the checkbox, the checkBox_Checke dChanged event is
not firing. Its not even hitting the function.
Any suggestions
-- Steven
"Peng Jie" <Pe*****@discus sions.microsoft .com> wrote in message
news:31******** *************** ***********@mic rosoft.com... What I mean is you can add
checkBoxArray[BoxCount].AutoPostBack = true;
into your foreach statement. Then you can fire server side event and call CheckedChanged function.
"Steven" wrote:
Hello Peng,
Could you please tell me, where should I set AutoPostBack="T rue" in the below code. I tried in checkBox_Checke dChanged function. But seems I'm missing something.
Regards Steven
"Peng Jie" <Pe*****@discus sions.microsoft .com> wrote in message news:2A******** *************** ***********@mic rosoft.com... > Hi Steven, > > I think you should set AutoPostBack="T rue". > > Jie > > "Steven" wrote: > >> I create the checkboxes dynamically on my webform (aspx). after I >> create >> them, when I check any of the checkboxes, nothing happens. Here is my >> code >> ... >> >> ArrayList LayerNameList1 = LayerNameList; >> >> CheckBox[] checkBoxArray; >> int BoxCount = 0; >> HtmlTableRow newRow; >> HtmlTableCell FieldCell; >> >> System.Web.UI.H tmlControls.Htm lTable ContainerTable = new HtmlTable(); >> checkBoxArray = new CheckBox[250]; >> foreach(string item in LayerNameList1) >> { >> newRow = new HtmlTableRow(); >> FieldCell = new HtmlTableCell() ; >> FieldCell.Style .Add("font-family", "Arial"); >> FieldCell.Style .Add("font-size", "smaller"); >> checkBoxArray[BoxCount] = new CheckBox(); >> checkBoxArray[BoxCount].ID = Convert.ToStrin g(BoxCount); >> checkBoxArray[BoxCount].Text = item; >> >> checkBoxArray[BoxCount].CheckedChanged += new >> System.EventHan dler(checkBox_C heckedChanged); >> >> FieldCell.Contr ols.Add(checkBo xArray[BoxCount]); >> newRow.Controls .Add(FieldCell) ; >> ContainerTable. Controls.Add(ne wRow); >> BoxCount++; >> } >> this.placeHolde r.Controls.Add( ContainerTable) ; >> } >> >> public void checkBox_Checke dChanged(object sender, System.EventArg s e) >> { >> CheckBox cb = (CheckBox) sender; >> >> if (cb.Checked) >> { testdel.Text = "1"; } >> else >> { testdel.Text = "2"; >> } >> } >> >> Any suggestions? >> >> Regards >> Praveen >> >> >> >> >>
Copied your code into a empty web form, like below,
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
// test for log4net status
ILog Log =
LogManager.GetL ogger(System.Re flection.Method Base.GetCurrent Method().Declar ingType);
Log.Info("Defau lt page.");
ArrayList LayerNameList1 = new ArrayList();
LayerNameList1. Add("test1");
LayerNameList1. Add("test2");
LayerNameList1. Add("test3");
CheckBox[] checkBoxArray;
int BoxCount = 0;
HtmlTableRow newRow;
HtmlTableCell FieldCell;
System.Web.UI.H tmlControls.Htm lTable ContainerTable = new HtmlTable();
checkBoxArray = new CheckBox[250];
foreach(string item in LayerNameList1)
{
newRow = new HtmlTableRow();
FieldCell = new HtmlTableCell() ;
FieldCell.Style .Add("font-family", "Arial");
FieldCell.Style .Add("font-size", "smaller");
checkBoxArray[BoxCount] = new CheckBox();
checkBoxArray[BoxCount].ID = Convert.ToStrin g(BoxCount);
checkBoxArray[BoxCount].Text = item;
checkBoxArray[BoxCount].AutoPostBack = true;
checkBoxArray[BoxCount].CheckedChanged += new
System.EventHan dler(checkBox_C heckedChanged);
FieldCell.Contr ols.Add(checkBo xArray[BoxCount]);
newRow.Controls .Add(FieldCell) ;
ContainerTable. Controls.Add(ne wRow);
BoxCount++;
}
this.placeHolde r.Controls.Add( ContainerTable) ;
}
public void checkBox_Checke dChanged(object sender, System.EventArg s e)
{
CheckBox cb = (CheckBox) sender;
if (cb.Checked)
{ testdel.Text = "1"; }
else
{
testdel.Text = "2";
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
It works for me. Did you create checkboxes in pageload?
"Steven" wrote: Hello Peng,
I tried this .. checkBoxArray[BoxCount].AutoPostBack = true;
checkBoxArray[BoxCount].CheckedChanged += new System.EventHan dler(checkBox_C heckedChanged11 ); but some how when I check the checkbox, the checkBox_Checke dChanged event is not firing. Its not even hitting the function. Any suggestions
-- Steven "Peng Jie" <Pe*****@discus sions.microsoft .com> wrote in message news:31******** *************** ***********@mic rosoft.com... What I mean is you can add
checkBoxArray[BoxCount].AutoPostBack = true;
into your foreach statement. Then you can fire server side event and call CheckedChanged function.
"Steven" wrote:
Hello Peng,
Could you please tell me, where should I set AutoPostBack="T rue" in the below code. I tried in checkBox_Checke dChanged function. But seems I'm missing something.
Regards Steven
"Peng Jie" <Pe*****@discus sions.microsoft .com> wrote in message news:2A******** *************** ***********@mic rosoft.com... > Hi Steven, > > I think you should set AutoPostBack="T rue". > > Jie > > "Steven" wrote: > >> I create the checkboxes dynamically on my webform (aspx). after I >> create >> them, when I check any of the checkboxes, nothing happens. Here is my >> code >> ... >> >> ArrayList LayerNameList1 = LayerNameList; >> >> CheckBox[] checkBoxArray; >> int BoxCount = 0; >> HtmlTableRow newRow; >> HtmlTableCell FieldCell; >> >> System.Web.UI.H tmlControls.Htm lTable ContainerTable = new HtmlTable(); >> checkBoxArray = new CheckBox[250]; >> foreach(string item in LayerNameList1) >> { >> newRow = new HtmlTableRow(); >> FieldCell = new HtmlTableCell() ; >> FieldCell.Style .Add("font-family", "Arial"); >> FieldCell.Style .Add("font-size", "smaller"); >> checkBoxArray[BoxCount] = new CheckBox(); >> checkBoxArray[BoxCount].ID = Convert.ToStrin g(BoxCount); >> checkBoxArray[BoxCount].Text = item; >> >> checkBoxArray[BoxCount].CheckedChanged += new >> System.EventHan dler(checkBox_C heckedChanged); >> >> FieldCell.Contr ols.Add(checkBo xArray[BoxCount]); >> newRow.Controls .Add(FieldCell) ; >> ContainerTable. Controls.Add(ne wRow); >> BoxCount++; >> } >> this.placeHolde r.Controls.Add( ContainerTable) ; >> } >> >> public void checkBox_Checke dChanged(object sender, System.EventArg s e) >> { >> CheckBox cb = (CheckBox) sender; >> >> if (cb.Checked) >> { testdel.Text = "1"; } >> else >> { testdel.Text = "2"; >> } >> } >> >> Any suggestions? >> >> Regards >> Praveen >> >> >> >> >>
Copied your code into a empty web form, like below,
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
// test for log4net status
ILog Log =
LogManager.GetL ogger(System.Re flection.Method Base.GetCurrent Method().Declar ingType);
Log.Info("Defau lt page.");
ArrayList LayerNameList1 = new ArrayList();
LayerNameList1. Add("test1");
LayerNameList1. Add("test2");
LayerNameList1. Add("test3");
CheckBox[] checkBoxArray;
int BoxCount = 0;
HtmlTableRow newRow;
HtmlTableCell FieldCell;
System.Web.UI.H tmlControls.Htm lTable ContainerTable = new HtmlTable();
checkBoxArray = new CheckBox[250];
foreach(string item in LayerNameList1)
{
newRow = new HtmlTableRow();
FieldCell = new HtmlTableCell() ;
FieldCell.Style .Add("font-family", "Arial");
FieldCell.Style .Add("font-size", "smaller");
checkBoxArray[BoxCount] = new CheckBox();
checkBoxArray[BoxCount].ID = Convert.ToStrin g(BoxCount);
checkBoxArray[BoxCount].Text = item;
checkBoxArray[BoxCount].AutoPostBack = true;
checkBoxArray[BoxCount].CheckedChanged += new
System.EventHan dler(checkBox_C heckedChanged);
FieldCell.Contr ols.Add(checkBo xArray[BoxCount]);
newRow.Controls .Add(FieldCell) ;
ContainerTable. Controls.Add(ne wRow);
BoxCount++;
}
this.placeHolde r.Controls.Add( ContainerTable) ;
}
public void checkBox_Checke dChanged(object sender, System.EventArg s e)
{
CheckBox cb = (CheckBox) sender;
if (cb.Checked)
{ testdel.Text = "1"; }
else
{
testdel.Text = "2";
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
It works for me. Did you create checkboxes in pageload?
"Steven" wrote: Hello Peng,
I tried this .. checkBoxArray[BoxCount].AutoPostBack = true;
checkBoxArray[BoxCount].CheckedChanged += new System.EventHan dler(checkBox_C heckedChanged11 ); but some how when I check the checkbox, the checkBox_Checke dChanged event is not firing. Its not even hitting the function. Any suggestions
-- Steven "Peng Jie" <Pe*****@discus sions.microsoft .com> wrote in message news:31******** *************** ***********@mic rosoft.com... What I mean is you can add
checkBoxArray[BoxCount].AutoPostBack = true;
into your foreach statement. Then you can fire server side event and call CheckedChanged function.
"Steven" wrote:
Hello Peng,
Could you please tell me, where should I set AutoPostBack="T rue" in the below code. I tried in checkBox_Checke dChanged function. But seems I'm missing something.
Regards Steven
"Peng Jie" <Pe*****@discus sions.microsoft .com> wrote in message news:2A******** *************** ***********@mic rosoft.com... > Hi Steven, > > I think you should set AutoPostBack="T rue". > > Jie > > "Steven" wrote: > >> I create the checkboxes dynamically on my webform (aspx). after I >> create >> them, when I check any of the checkboxes, nothing happens. Here is my >> code >> ... >> >> ArrayList LayerNameList1 = LayerNameList; >> >> CheckBox[] checkBoxArray; >> int BoxCount = 0; >> HtmlTableRow newRow; >> HtmlTableCell FieldCell; >> >> System.Web.UI.H tmlControls.Htm lTable ContainerTable = new HtmlTable(); >> checkBoxArray = new CheckBox[250]; >> foreach(string item in LayerNameList1) >> { >> newRow = new HtmlTableRow(); >> FieldCell = new HtmlTableCell() ; >> FieldCell.Style .Add("font-family", "Arial"); >> FieldCell.Style .Add("font-size", "smaller"); >> checkBoxArray[BoxCount] = new CheckBox(); >> checkBoxArray[BoxCount].ID = Convert.ToStrin g(BoxCount); >> checkBoxArray[BoxCount].Text = item; >> >> checkBoxArray[BoxCount].CheckedChanged += new >> System.EventHan dler(checkBox_C heckedChanged); >> >> FieldCell.Contr ols.Add(checkBo xArray[BoxCount]); >> newRow.Controls .Add(FieldCell) ; >> ContainerTable. Controls.Add(ne wRow); >> BoxCount++; >> } >> this.placeHolde r.Controls.Add( ContainerTable) ; >> } >> >> public void checkBox_Checke dChanged(object sender, System.EventArg s e) >> { >> CheckBox cb = (CheckBox) sender; >> >> if (cb.Checked) >> { testdel.Text = "1"; } >> else >> { testdel.Text = "2"; >> } >> } >> >> Any suggestions? >> >> Regards >> Praveen >> >> >> >> >>
Copied your code into a empty web form, like below,
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
// test for log4net status
ILog Log =
LogManager.GetL ogger(System.Re flection.Method Base.GetCurrent Method().Declar ingType);
Log.Info("Defau lt page.");
ArrayList LayerNameList1 = new ArrayList();
LayerNameList1. Add("test1");
LayerNameList1. Add("test2");
LayerNameList1. Add("test3");
CheckBox[] checkBoxArray;
int BoxCount = 0;
HtmlTableRow newRow;
HtmlTableCell FieldCell;
System.Web.UI.H tmlControls.Htm lTable ContainerTable = new HtmlTable();
checkBoxArray = new CheckBox[250];
foreach(string item in LayerNameList1)
{
newRow = new HtmlTableRow();
FieldCell = new HtmlTableCell() ;
FieldCell.Style .Add("font-family", "Arial");
FieldCell.Style .Add("font-size", "smaller");
checkBoxArray[BoxCount] = new CheckBox();
checkBoxArray[BoxCount].ID = Convert.ToStrin g(BoxCount);
checkBoxArray[BoxCount].Text = item;
checkBoxArray[BoxCount].AutoPostBack = true;
checkBoxArray[BoxCount].CheckedChanged += new
System.EventHan dler(checkBox_C heckedChanged);
FieldCell.Contr ols.Add(checkBo xArray[BoxCount]);
newRow.Controls .Add(FieldCell) ;
ContainerTable. Controls.Add(ne wRow);
BoxCount++;
}
this.placeHolde r.Controls.Add( ContainerTable) ;
}
public void checkBox_Checke dChanged(object sender, System.EventArg s e)
{
CheckBox cb = (CheckBox) sender;
if (cb.Checked)
{ testdel.Text = "1"; }
else
{
testdel.Text = "2";
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
It works for me. Did you create checkboxes in pageload?
Copied your code into a empty web form, like below,
It exactly works for me. Did you create checkboxes in pageload?
"Steven" wrote: Hello Peng,
I tried this .. checkBoxArray[BoxCount].AutoPostBack = true;
checkBoxArray[BoxCount].CheckedChanged += new System.EventHan dler(checkBox_C heckedChanged11 ); but some how when I check the checkbox, the checkBox_Checke dChanged event is not firing. Its not even hitting the function. Any suggestions
-- Steven "Peng Jie" <Pe*****@discus sions.microsoft .com> wrote in message news:31******** *************** ***********@mic rosoft.com... What I mean is you can add
checkBoxArray[BoxCount].AutoPostBack = true;
into your foreach statement. Then you can fire server side event and call CheckedChanged function.
"Steven" wrote:
Hello Peng,
Could you please tell me, where should I set AutoPostBack="T rue" in the below code. I tried in checkBox_Checke dChanged function. But seems I'm missing something.
Regards Steven
"Peng Jie" <Pe*****@discus sions.microsoft .com> wrote in message news:2A******** *************** ***********@mic rosoft.com... > Hi Steven, > > I think you should set AutoPostBack="T rue". > > Jie > > "Steven" wrote: > >> I create the checkboxes dynamically on my webform (aspx). after I >> create >> them, when I check any of the checkboxes, nothing happens. Here is my >> code >> ... >> >> ArrayList LayerNameList1 = LayerNameList; >> >> CheckBox[] checkBoxArray; >> int BoxCount = 0; >> HtmlTableRow newRow; >> HtmlTableCell FieldCell; >> >> System.Web.UI.H tmlControls.Htm lTable ContainerTable = new HtmlTable(); >> checkBoxArray = new CheckBox[250]; >> foreach(string item in LayerNameList1) >> { >> newRow = new HtmlTableRow(); >> FieldCell = new HtmlTableCell() ; >> FieldCell.Style .Add("font-family", "Arial"); >> FieldCell.Style .Add("font-size", "smaller"); >> checkBoxArray[BoxCount] = new CheckBox(); >> checkBoxArray[BoxCount].ID = Convert.ToStrin g(BoxCount); >> checkBoxArray[BoxCount].Text = item; >> >> checkBoxArray[BoxCount].CheckedChanged += new >> System.EventHan dler(checkBox_C heckedChanged); >> >> FieldCell.Contr ols.Add(checkBo xArray[BoxCount]); >> newRow.Controls .Add(FieldCell) ; >> ContainerTable. Controls.Add(ne wRow); >> BoxCount++; >> } >> this.placeHolde r.Controls.Add( ContainerTable) ; >> } >> >> public void checkBox_Checke dChanged(object sender, System.EventArg s e) >> { >> CheckBox cb = (CheckBox) sender; >> >> if (cb.Checked) >> { testdel.Text = "1"; } >> else >> { testdel.Text = "2"; >> } >> } >> >> Any suggestions? >> >> Regards >> Praveen >> >> >> >> >>
Thank you for the code and explanation.
If I recreate the controls on page load everything works fine. But I do not
want to recreate the controls on page load. I just want to create the check
boxes only when I click the button.
Regards
Steven
"Peng Jie" <Pe*****@discus sions.microsoft .com> wrote in message
news:5F******** *************** ***********@mic rosoft.com... Copied your code into a empty web form, like below,
It exactly works for me. Did you create checkboxes in pageload? "Steven" wrote:
Hello Peng,
I tried this .. checkBoxArray[BoxCount].AutoPostBack = true;
checkBoxArray[BoxCount].CheckedChanged += new System.EventHan dler(checkBox_C heckedChanged11 ); but some how when I check the checkbox, the checkBox_Checke dChanged event is not firing. Its not even hitting the function. Any suggestions
-- Steven "Peng Jie" <Pe*****@discus sions.microsoft .com> wrote in message news:31******** *************** ***********@mic rosoft.com... > What I mean is you can add > > checkBoxArray[BoxCount].AutoPostBack = true; > > into your foreach statement. > Then you can fire server side event and call CheckedChanged function. > > "Steven" wrote: > >> Hello Peng, >> >> Could you please tell me, where should I set AutoPostBack="T rue" in >> the >> below code. I tried in checkBox_Checke dChanged function. But seems I'm >> missing something. >> >> Regards >> Steven >> >> "Peng Jie" <Pe*****@discus sions.microsoft .com> wrote in message >> news:2A******** *************** ***********@mic rosoft.com... >> > Hi Steven, >> > >> > I think you should set AutoPostBack="T rue". >> > >> > Jie >> > >> > "Steven" wrote: >> > >> >> I create the checkboxes dynamically on my webform (aspx). after I >> >> create >> >> them, when I check any of the checkboxes, nothing happens. Here is >> >> my >> >> code >> >> ... >> >> >> >> ArrayList LayerNameList1 = LayerNameList; >> >> >> >> CheckBox[] checkBoxArray; >> >> int BoxCount = 0; >> >> HtmlTableRow newRow; >> >> HtmlTableCell FieldCell; >> >> >> >> System.Web.UI.H tmlControls.Htm lTable ContainerTable = new >> >> HtmlTable(); >> >> checkBoxArray = new CheckBox[250]; >> >> foreach(string item in LayerNameList1) >> >> { >> >> newRow = new HtmlTableRow(); >> >> FieldCell = new HtmlTableCell() ; >> >> FieldCell.Style .Add("font-family", "Arial"); >> >> FieldCell.Style .Add("font-size", "smaller"); >> >> checkBoxArray[BoxCount] = new CheckBox(); >> >> checkBoxArray[BoxCount].ID = Convert.ToStrin g(BoxCount); >> >> checkBoxArray[BoxCount].Text = item; >> >> >> >> checkBoxArray[BoxCount].CheckedChanged += new >> >> System.EventHan dler(checkBox_C heckedChanged); >> >> >> >> FieldCell.Contr ols.Add(checkBo xArray[BoxCount]); >> >> newRow.Controls .Add(FieldCell) ; >> >> ContainerTable. Controls.Add(ne wRow); >> >> BoxCount++; >> >> } >> >> this.placeHolde r.Controls.Add( ContainerTable) ; >> >> } >> >> >> >> public void checkBox_Checke dChanged(object sender, System.EventArg s >> >> e) >> >> { >> >> CheckBox cb = (CheckBox) sender; >> >> >> >> if (cb.Checked) >> >> { testdel.Text = "1"; } >> >> else >> >> { testdel.Text = "2"; >> >> } >> >> } >> >> >> >> Any suggestions? >> >> >> >> Regards >> >> Praveen >> >> >> >> >> >> >> >> >> >> >> >> >> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: middletree |
last post by:
Hate to post this in a separate post, but felt that the last thread was too
far down to get noticed. It is called dynamic checkboxes, and it contained
some good advice for me, but it led to another question, and I wanted to go
ahead and post my question here in hopes of getting an answer.
The advice given to me about having a number of...
|
by: DylanM |
last post by:
I have some checkboxes that are generated from the results of a database search. At the moment, the checkboxes are part of a table making up a form. Users are going through the form, clicking the boxes and saving to the database at the end with the 'Submit' command button.
Is it possible to save the changes as the checkboxes are clicked? I...
|
by: trank |
last post by:
I created some checkboxes(<input type=checkbox>) dynamically,and then I'd
like to access these checkboxes in code behind using C#.
For they are not standard controls like Windows Checkbox, I can't catch it
by FindControl().....how can i do this?
Many thanks a lot!
By trank
trank@dynamic-x.net
|
by: Jack Black |
last post by:
Using VS.Net 2k3 to build ASP.Net app with VB code-behind pages...
Hi, all! I've been struggling with getting a dynamically-generated
CheckBoxList generated. I've finally been able to get the list
generated, but now there are two problems I haven't been able to
overcome:
1) ASP.Net is munging the checkbox ID/Names of the checkboxes: I...
|
by: clinttoris |
last post by:
Hello Experts,
I have been told to post this in the Javascript forum as I want to do
this client side just before my form gets submitted. Once the user
clicks the submit button a javascript function needs to run and
validate all the checkboxes on my form and make sure none of them are
unchecked. I suck at Javascript and my problem is...
| |
by: Kevin R |
last post by:
This is one of the weirdest problems I have ever run into. I have had to
trim down a bunch of code to give a sample that is more easily readable by
those who will view this. Here is the problem:
I dynamically add an htmlcheckbox to a webform in the pages render and set
the checked value to true. When the page loads, if I remove the check...
|
by: tamari |
last post by:
I have a strange problem changing the checked value of dynamically created checkboxes within code.
This is what is happening. Depending what is selected I create checkboxes within a panel. These work very well if I click on them manually, but sometimes I need to check or uncheck some of the checkboxes depending on further input.
To change...
|
by: scottSD |
last post by:
Hi everyone. this is my first post here, but i've found quite a bit of great information from reading the forums in the past.
i'm not sure if what i'm trying to do is possible or not, but here it is:
i'm creating a dynamic list of checkboxes, basically to allow access to client information on a user by user basis. i use ajax to bring back...
|
by: galien8 |
last post by:
Dear Newsgroup Readers,
I have a problem with dynamic controls, in a DotNetNuke module, and
event handlers in VB.NET ASP.NET 2.0. Events are firing and being
handled, sometimes good but also sometimes in a wrong way. I always
unchecked the first of the list (See Also Source Code Below):
CheckBox1 sender ID = D0
CheckBox2
CheckBox3
|
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...
|
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...
| |
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...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |