473,400 Members | 2,145 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,400 software developers and data experts.

Events not firing


Hi,

I am adding controls dynamically in a WebForm, but none of these controls' events fire. Here is the class code I am using. I have tried so many things, but nothing works :-(

namespace WebApplication1

{

using System;

using System.Data;

using System.Collections;

using System.Drawing;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.ComponentModel;

/// <summary>

/// Summary description for WebUserControl1.

/// </summary>

public class Tracking : System.Web.UI.WebControls.WebControl

{

private ArrayList arr = new ArrayList();

private System.Web.UI.WebControls.Table m_Table = new Table();

private System.Web.UI.WebControls.Button btn = new Button();

//private System.Web.UI.WebControls.Label lbl = new Label();

//private System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();

//private System.Web.UI.WebControls.DropDownList lst = new DropDownList();

public void buildTable(TableTracking trk)

{

//m_Table.BorderStyle = BorderStyle.Solid;

//m_Table.BorderWidth = Unit.Pixel(2);

//m_Table.BorderColor = Color.DarkBlue;

System.Web.UI.WebControls.TableRow row = new TableRow();

System.Web.UI.WebControls.TableCell cell = new TableCell();

System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();

if (trk.Editable==true)

{

//btn.Text = "<font face=Verdana size=1>" + "Edit Me";

btn.Text = "Edit";

img.ImageUrl = "Images/img_sec/edit_pencil.gif";

cell.Height = 5;

//cell.HorizontalAlign = HorizontalAlign.Right;

cell.Width = m_Table.Width;

cell.Controls.Add(img);

cell.Controls.Add(new LiteralControl("&nbsp;"));

//cell.Controls.Add(new LiteralControl("<font face=Verdana size=1>"));

cell.Controls.Add(btn);
row.Cells.Add(cell);

m_Table.Rows.Add(row);

}

else

{

btn.Visible = false;

img.Visible = false;

}

m_Table.Width = trk.Width;

m_Table.Height = trk.Height;

}

public void buildItem(ArrayList items)

{

System.Web.UI.WebControls.TableRow row = new TableRow();

System.Web.UI.WebControls.TableCell cell = null;
//cell.BorderStyle = BorderStyle.Solid;

//cell.BorderWidth = Unit.Pixel(1);

//cell.BorderColor = Color.DarkBlue;

int currentRow = 0;

int previousRow = 0;

foreach (Item i in items)

{

currentRow = i.Row;

if (currentRow != previousRow && previousRow != 0)

{

m_Table.Rows.Add(row);

row = new TableRow();

}

cell = new TableCell();

cell.HorizontalAlign = HorizontalAlign.Center;

cell.Width = i.Width;

//cell.Height = Convert.ToString(i.Height);

if (i.Type == "Label")

{

System.Web.UI.WebControls.Label lbl = new Label();

cell.Controls.Add(new LiteralControl("<font style='FONT-WEIGHT: bold' face=Verdana size=1>"));

lbl.Text = (string)i.Content[0];

cell.Controls.Add(lbl);

}

else if (i.Type == "Image")

{

System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();

img.ImageUrl = (string)i.Content[0];

cell.Controls.Add(img);

}

else if (i.Type == "DropDownList")

{

System.Web.UI.WebControls.DropDownList lst = new DropDownList();

arr.Add(lst);

for (int n=0; n<i.Content.Count; n++)

{

lst.Items.Add((string)i.Content[n]);

}

lst.Visible = false;

cell.Controls.Add(lst);

lst.SelectedIndexChanged+=new EventHandler(lst_SelectedIndexChanged);

}

row.Cells.Add(cell);

previousRow = i.Row;

}

m_Table.Rows.Add(row);

}

protected override void Render(HtmlTextWriter writer)

{

Controls.Clear();

Controls.Add(m_Table);

base.Render (writer);

}

private void Page_Load(object sender, System.EventArgs e)

{

if (Page.IsPostBack)

{

foreach(DropDownList lst in arr)

{

lst.Visible = true;

}

btn.Text = "Save";

}

}
#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}
/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

private void lst_SelectedIndexChanged(object sender, EventArgs e)

{

Console.WriteLine("OK");

}

}

}
This is how the control is set up in the Web Form:
<WEBAPPLICATION1:TRACKING id=trck1 runat=server></WEBAPPLICATION1:TRACKING>

Any idea on what could be wrong?

Thanks.
Mike

Nov 18 '05 #1
3 2269
I may be wrong, but suspect that you actually have one event firing - Page_Load. To figure out why other events are not firing, first understand why Page_Load is firing. It has a delegate defined in private void InitializeComponent()... this.Load += new System.EventHandler(this.Page_Load);

What that line specifies is that for the this.Load event, execute the code in the Page_Load procedure.
The syntax is something like this:
this.Load += new System.EventHandler(this.Page_Load);
someObjectOrControl.EventName += new System.EventHandler(thisClass.EventProcedureName);
So, what you need to do is add a delegate (like currently specified for Page_Load) for each of the events you want to handle. You already have one, but I suspect it's in the wrong place. Find the following line in your code:
lst.SelectedIndexChanged+=new EventHandler(lst_SelectedIndexChanged);
and move it to your private void InitializeComponent() routine. Also, for fun, try to be consistent with what the framework already does by specifying "new System.EventHandler"... rather than "new EventHandler" (yes, you could probably get away without specifying system because you have using System; but just for consistency, blah blah blah.

Also, get some indentation going so you can see exactly where your namespace begins and ends, where the class begins and ends, etc. Make your code more readable and you might be able to eyeball some issues.

Also, don't expect Console.WriteLine to work in an asp.net Web app. you might try Response.Write("Hello World"); instead.

HTH

"Mike" <no****@nospam.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...

Hi,

I am adding controls dynamically in a WebForm, but none of these controls' events fire. Here is the class code I am using. I have tried so many things, but nothing works :-(

namespace WebApplication1

{

using System;

using System.Data;

using System.Collections;

using System.Drawing;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.ComponentModel;

/// <summary>

/// Summary description for WebUserControl1.

/// </summary>

public class Tracking : System.Web.UI.WebControls.WebControl

{

private ArrayList arr = new ArrayList();

private System.Web.UI.WebControls.Table m_Table = new Table();

private System.Web.UI.WebControls.Button btn = new Button();

//private System.Web.UI.WebControls.Label lbl = new Label();

//private System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();

//private System.Web.UI.WebControls.DropDownList lst = new DropDownList();

public void buildTable(TableTracking trk)

{

//m_Table.BorderStyle = BorderStyle.Solid;

//m_Table.BorderWidth = Unit.Pixel(2);

//m_Table.BorderColor = Color.DarkBlue;

System.Web.UI.WebControls.TableRow row = new TableRow();

System.Web.UI.WebControls.TableCell cell = new TableCell();

System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();

if (trk.Editable==true)

{

//btn.Text = "<font face=Verdana size=1>" + "Edit Me";

btn.Text = "Edit";

img.ImageUrl = "Images/img_sec/edit_pencil.gif";

cell.Height = 5;

//cell.HorizontalAlign = HorizontalAlign.Right;

cell.Width = m_Table.Width;

cell.Controls.Add(img);

cell.Controls.Add(new LiteralControl("&nbsp;"));

//cell.Controls.Add(new LiteralControl("<font face=Verdana size=1>"));

cell.Controls.Add(btn);
row.Cells.Add(cell);

m_Table.Rows.Add(row);

}

else

{

btn.Visible = false;

img.Visible = false;

}

m_Table.Width = trk.Width;

m_Table.Height = trk.Height;

}

public void buildItem(ArrayList items)

{

System.Web.UI.WebControls.TableRow row = new TableRow();

System.Web.UI.WebControls.TableCell cell = null;
//cell.BorderStyle = BorderStyle.Solid;

//cell.BorderWidth = Unit.Pixel(1);

//cell.BorderColor = Color.DarkBlue;

int currentRow = 0;

int previousRow = 0;

foreach (Item i in items)

{

currentRow = i.Row;

if (currentRow != previousRow && previousRow != 0)

{

m_Table.Rows.Add(row);

row = new TableRow();

}

cell = new TableCell();

cell.HorizontalAlign = HorizontalAlign.Center;

cell.Width = i.Width;

//cell.Height = Convert.ToString(i.Height);

if (i.Type == "Label")

{

System.Web.UI.WebControls.Label lbl = new Label();

cell.Controls.Add(new LiteralControl("<font style='FONT-WEIGHT: bold' face=Verdana size=1>"));

lbl.Text = (string)i.Content[0];

cell.Controls.Add(lbl);

}

else if (i.Type == "Image")

{

System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();

img.ImageUrl = (string)i.Content[0];

cell.Controls.Add(img);

}

else if (i.Type == "DropDownList")

{

System.Web.UI.WebControls.DropDownList lst = new DropDownList();

arr.Add(lst);

for (int n=0; n<i.Content.Count; n++)

{

lst.Items.Add((string)i.Content[n]);

}

lst.Visible = false;

cell.Controls.Add(lst);

lst.SelectedIndexChanged+=new EventHandler(lst_SelectedIndexChanged);

}

row.Cells.Add(cell);

previousRow = i.Row;

}

m_Table.Rows.Add(row);

}

protected override void Render(HtmlTextWriter writer)

{

Controls.Clear();

Controls.Add(m_Table);

base.Render (writer);

}

private void Page_Load(object sender, System.EventArgs e)

{

if (Page.IsPostBack)

{

foreach(DropDownList lst in arr)

{

lst.Visible = true;

}

btn.Text = "Save";

}

}
#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}
/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

private void lst_SelectedIndexChanged(object sender, EventArgs e)

{

Console.WriteLine("OK");

}

}

}
This is how the control is set up in the Web Form:
<WEBAPPLICATION1:TRACKING id=trck1 runat=server></WEBAPPLICATION1:TRACKING>

Any idea on what could be wrong?

Thanks.
Mike

Nov 18 '05 #2
Hi Mike

Robert is right about the missing delegates. They are usually added
automatically to the InitializeComponent method when you drag a control
onto the form in VS.net. A word of warning though. I have had a lot of
trouble, as have a lot of other people if you check through the
newsgroups, with manually adding items to the InitializeComponent
method. There is a good reason why the comment says 'do not modify
the contents of this method with the code editor.' It seems that each
time you go into design view, or make a change in design view, Visual
Studio deletes and rewrites the contents of this method. I have found
that often it isn't too successful in doing this if you have altered the
contents of the method and consequently events seem to stop firing as
the delegates have been erased. This has been fixed in .NET 2.0 with the
introduction of partial classess but in 1.1 the best workaround I could
come up with is to not put them in there in the first place but to put
them in the constructor where they will be left alone by VS.

Hope this helps

Graham
Robert Howells wrote:
I may be wrong, but suspect that you actually have one event firing -
Page_Load. To figure out why other events are not firing, first
understand why Page_Load is firing. It has a delegate defined in private
void InitializeComponent()... this.Load += new
System.EventHandler(this.Page_Load);

What that line specifies is that for the this.Load event, execute the
code in the Page_Load procedure.
The syntax is something like this:
this.Load += new System.EventHandler(this.Page_Load);
someObjectOrControl.EventName += new
System.EventHandler(thisClass.EventProcedureName);
So, what you need to do is add a delegate (like currently specified for
Page_Load) for each of the events you want to handle. You already have
one, but I suspect it's in the wrong place. Find the following line in
your code:
lst.SelectedIndexChanged+=new EventHandler(lst_SelectedIndexChanged);
and move it to your private void InitializeComponent() routine. Also,
for fun, try to be consistent with what the framework already does by
specifying "new System.EventHandler"... rather than "new EventHandler"
(yes, you could probably get away without specifying system because you
have using System; but just for consistency, blah blah blah.

Also, get some indentation going so you can see exactly where your
namespace begins and ends, where the class begins and ends, etc. Make
your code more readable and you might be able to eyeball some issues.

Also, don't expect Console.WriteLine to work in an asp.net Web app. you
might try Response.Write("Hello World"); instead.

HTH


"Mike" <no****@nospam.com <mailto:no****@nospam.com>> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...

Hi,

I am adding controls dynamically in a WebForm, but none of these
controls' events fire. Here is the class code I am using. I have
tried so many things, but nothing works :-(
namespace WebApplication1

{

using System;

using System.Data;

using System.Collections;

using System.Drawing;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.ComponentModel;

/// <summary>

/// Summary description for WebUserControl1.

/// </summary>

public class Tracking : System.Web.UI.WebControls.WebControl

{

private ArrayList arr = new ArrayList();

private System.Web.UI.WebControls.Table m_Table = new Table();

private System.Web.UI.WebControls.Button btn = new Button();

//private System.Web.UI.WebControls.Label lbl = new Label();

//private System.Web.UI.WebControls.Image img = new
System.Web.UI.WebControls.Image();

//private System.Web.UI.WebControls.DropDownList lst = new
DropDownList();

public void buildTable(TableTracking trk)

{

//m_Table.BorderStyle = BorderStyle.Solid;

//m_Table.BorderWidth = Unit.Pixel(2);

//m_Table.BorderColor = Color.DarkBlue;

System.Web.UI.WebControls.TableRow row = new TableRow();

System.Web.UI.WebControls.TableCell cell = new TableCell();

System.Web.UI.WebControls.Image img = new
System.Web.UI.WebControls.Image();

if (trk.Editable==true)

{

//btn.Text = "<font face=Verdana size=1>" + "Edit Me";

btn.Text = "Edit";

img.ImageUrl = "Images/img_sec/edit_pencil.gif";

cell.Height = 5;

//cell.HorizontalAlign = HorizontalAlign.Right;

cell.Width = m_Table.Width;

cell.Controls.Add(img);

cell.Controls.Add(new LiteralControl("&nbsp;"));

//cell.Controls.Add(new LiteralControl("<font face=Verdana size=1>"));

cell.Controls.Add(btn);

row.Cells.Add(cell);

m_Table.Rows.Add(row);

}

else

{

btn.Visible = false;

img.Visible = false;

}

m_Table.Width = trk.Width;

m_Table.Height = trk.Height;

}

public void buildItem(ArrayList items)

{

System.Web.UI.WebControls.TableRow row = new TableRow();

System.Web.UI.WebControls.TableCell cell = null;

//cell.BorderStyle = BorderStyle.Solid;

//cell.BorderWidth = Unit.Pixel(1);

//cell.BorderColor = Color.DarkBlue;

int currentRow = 0;

int previousRow = 0;

foreach (Item i in items)

{

currentRow = i.Row;

if (currentRow != previousRow && previousRow != 0)

{

m_Table.Rows.Add(row);

row = new TableRow();

}

cell = new TableCell();

cell.HorizontalAlign = HorizontalAlign.Center;

cell.Width = i.Width;

//cell.Height = Convert.ToString(i.Height);

if (i.Type == "Label")

{

System.Web.UI.WebControls.Label lbl = new Label();

cell.Controls.Add(new LiteralControl("<font style='FONT-WEIGHT:
bold' face=Verdana size=1>"));

lbl.Text = (string)i.Content[0];

cell.Controls.Add(lbl);

}

else if (i.Type == "Image")

{

System.Web.UI.WebControls.Image img = new
System.Web.UI.WebControls.Image();

img.ImageUrl = (string)i.Content[0];

cell.Controls.Add(img);

}

else if (i.Type == "DropDownList")

{

System.Web.UI.WebControls.DropDownList lst = new DropDownList();

arr.Add(lst);

for (int n=0; n<i.Content.Count; n++)

{

lst.Items.Add((string)i.Content[n]);

}

lst.Visible = false;

cell.Controls.Add(lst);

lst.SelectedIndexChanged+=new EventHandler(lst_SelectedIndexChanged);

}

row.Cells.Add(cell);

previousRow = i.Row;

}

m_Table.Rows.Add(row);

}

protected override void Render(HtmlTextWriter writer)

{

Controls.Clear();

Controls.Add(m_Table);

base.Render (writer);

}

private void Page_Load(object sender, System.EventArgs e)

{

if (Page.IsPostBack)

{

foreach(DropDownList lst in arr)

{

lst.Visible = true;

}

btn.Text = "Save";

}

}

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

private void lst_SelectedIndexChanged(object sender, EventArgs e)

{

Console.WriteLine("OK");

}

}

}
This is how the control is set up in the Web Form:
<WEBAPPLICATION1:TRACKING id=trck1
runat=server></WEBAPPLICATION1:TRACKING>

Any idea on what could be wrong?

Thanks.
Mike

Nov 18 '05 #3

Thanks Guys, your explanations were very helpful. I also found that removing the "Controls.Clear" statement from the "Render" method helped. With regards to the event handlers and delegates, I decided to keep them just after the instantiation of the dynamic control that I add to the Web Form.

Again, thanks a lot.
Mike

"Graham Pengelly" <gr****@REMOVEMEmainlineconsultants.com> wrote in message news:Od**************@TK2MSFTNGP10.phx.gbl...
Hi Mike

Robert is right about the missing delegates. They are usually added
automatically to the InitializeComponent method when you drag a control
onto the form in VS.net. A word of warning though. I have had a lot of
trouble, as have a lot of other people if you check through the
newsgroups, with manually adding items to the InitializeComponent
method. There is a good reason why the comment says 'do not modify
the contents of this method with the code editor.' It seems that each
time you go into design view, or make a change in design view, Visual
Studio deletes and rewrites the contents of this method. I have found
that often it isn't too successful in doing this if you have altered the
contents of the method and consequently events seem to stop firing as
the delegates have been erased. This has been fixed in .NET 2.0 with the
introduction of partial classess but in 1.1 the best workaround I could
come up with is to not put them in there in the first place but to put
them in the constructor where they will be left alone by VS.

Hope this helps

Graham
Robert Howells wrote:
I may be wrong, but suspect that you actually have one event firing -
Page_Load. To figure out why other events are not firing, first
understand why Page_Load is firing. It has a delegate defined in private
void InitializeComponent()... this.Load += new
System.EventHandler(this.Page_Load);

What that line specifies is that for the this.Load event, execute the
code in the Page_Load procedure.
The syntax is something like this:
this.Load += new System.EventHandler(this.Page_Load);
someObjectOrControl.EventName += new
System.EventHandler(thisClass.EventProcedureName);


So, what you need to do is add a delegate (like currently specified for
Page_Load) for each of the events you want to handle. You already have
one, but I suspect it's in the wrong place. Find the following line in
your code:
lst.SelectedIndexChanged+=new EventHandler(lst_SelectedIndexChanged);
and move it to your private void InitializeComponent() routine. Also,
for fun, try to be consistent with what the framework already does by
specifying "new System.EventHandler"... rather than "new EventHandler"
(yes, you could probably get away without specifying system because you
have using System; but just for consistency, blah blah blah.

Also, get some indentation going so you can see exactly where your
namespace begins and ends, where the class begins and ends, etc. Make
your code more readable and you might be able to eyeball some issues.

Also, don't expect Console.WriteLine to work in an asp.net Web app. you
might try Response.Write("Hello World"); instead.

HTH






"Mike" <no****@nospam.com <mailto:no****@nospam.com>> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...

Hi,

I am adding controls dynamically in a WebForm, but none of these
controls' events fire. Here is the class code I am using. I have
tried so many things, but nothing works :-(


namespace WebApplication1

{

using System;

using System.Data;

using System.Collections;

using System.Drawing;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.ComponentModel;

/// <summary>

/// Summary description for WebUserControl1.

/// </summary>

public class Tracking : System.Web.UI.WebControls.WebControl

{

private ArrayList arr = new ArrayList();

private System.Web.UI.WebControls.Table m_Table = new Table();

private System.Web.UI.WebControls.Button btn = new Button();

//private System.Web.UI.WebControls.Label lbl = new Label();

//private System.Web.UI.WebControls.Image img = new
System.Web.UI.WebControls.Image();

//private System.Web.UI.WebControls.DropDownList lst = new
DropDownList();

public void buildTable(TableTracking trk)

{

//m_Table.BorderStyle = BorderStyle.Solid;

//m_Table.BorderWidth = Unit.Pixel(2);

//m_Table.BorderColor = Color.DarkBlue;

System.Web.UI.WebControls.TableRow row = new TableRow();

System.Web.UI.WebControls.TableCell cell = new TableCell();

System.Web.UI.WebControls.Image img = new
System.Web.UI.WebControls.Image();

if (trk.Editable==true)

{

//btn.Text = "<font face=Verdana size=1>" + "Edit Me";

btn.Text = "Edit";

img.ImageUrl = "Images/img_sec/edit_pencil.gif";

cell.Height = 5;

//cell.HorizontalAlign = HorizontalAlign.Right;

cell.Width = m_Table.Width;

cell.Controls.Add(img);

cell.Controls.Add(new LiteralControl("&nbsp;"));

//cell.Controls.Add(new LiteralControl("<font face=Verdana size=1>"));

cell.Controls.Add(btn);

row.Cells.Add(cell);

m_Table.Rows.Add(row);

}

else

{

btn.Visible = false;

img.Visible = false;

}

m_Table.Width = trk.Width;

m_Table.Height = trk.Height;

}

public void buildItem(ArrayList items)

{

System.Web.UI.WebControls.TableRow row = new TableRow();

System.Web.UI.WebControls.TableCell cell = null;

//cell.BorderStyle = BorderStyle.Solid;

//cell.BorderWidth = Unit.Pixel(1);

//cell.BorderColor = Color.DarkBlue;

int currentRow = 0;

int previousRow = 0;

foreach (Item i in items)

{

currentRow = i.Row;

if (currentRow != previousRow && previousRow != 0)

{

m_Table.Rows.Add(row);

row = new TableRow();

}

cell = new TableCell();

cell.HorizontalAlign = HorizontalAlign.Center;

cell.Width = i.Width;

//cell.Height = Convert.ToString(i.Height);

if (i.Type == "Label")

{

System.Web.UI.WebControls.Label lbl = new Label();

cell.Controls.Add(new LiteralControl("<font style='FONT-WEIGHT:
bold' face=Verdana size=1>"));

lbl.Text = (string)i.Content[0];

cell.Controls.Add(lbl);

}

else if (i.Type == "Image")

{

System.Web.UI.WebControls.Image img = new
System.Web.UI.WebControls.Image();

img.ImageUrl = (string)i.Content[0];

cell.Controls.Add(img);

}

else if (i.Type == "DropDownList")

{

System.Web.UI.WebControls.DropDownList lst = new DropDownList();

arr.Add(lst);

for (int n=0; n<i.Content.Count; n++)

{

lst.Items.Add((string)i.Content[n]);

}

lst.Visible = false;

cell.Controls.Add(lst);

lst.SelectedIndexChanged+=new EventHandler(lst_SelectedIndexChanged);

}

row.Cells.Add(cell);

previousRow = i.Row;

}

m_Table.Rows.Add(row);

}

protected override void Render(HtmlTextWriter writer)

{

Controls.Clear();

Controls.Add(m_Table);

base.Render (writer);

}

private void Page_Load(object sender, System.EventArgs e)

{

if (Page.IsPostBack)

{

foreach(DropDownList lst in arr)

{

lst.Visible = true;

}

btn.Text = "Save";

}

}

#region Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

private void lst_SelectedIndexChanged(object sender, EventArgs e)

{

Console.WriteLine("OK");

}

}

}


This is how the control is set up in the Web Form:
<WEBAPPLICATION1:TRACKING id=trck1
runat=server></WEBAPPLICATION1:TRACKING>

Any idea on what could be wrong?

Thanks.
Mike


Nov 18 '05 #4

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

Similar topics

1
by: teb | last post by:
Hello all, Here is basically the situation. I have an empty div on my page. When I mouseover a word, the innerHTML of the div gets written with a table. The td elements all have onclick,...
14
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
9
by: Erik Frey | last post by:
Hi there, Just curious as to whether there's a clever way to see the events a control/object is firing off, perhaps written out to the debug console. It would be really handy to know which...
7
by: Denise | last post by:
I just realized the DataTable_RowChanging events were firing when I called Fill method of the DataAdapter! It fires TWICE for each row loaded. I thought these were only supposed to be called when...
0
by: RobKinney1 | last post by:
Hello, One of our C# apps (2.0) depends on a few events. One of them being DocumentComplete. Well, everything works fine with users that have IE 6 installed on their computers. But we noticed...
2
by: mswlogo | last post by:
I looked high and low for code to do this and finally found some VB code that did it right. This is a C# flavor of it. public event EventHandler<EventArgsMyEventToBeFired; public void...
1
by: TimmyTurner | last post by:
Hi all I'm working on a ASP.NET, C# project on Visual Studio 2005, using a MSDB in _vista_. My problem is that the events for the buttons are not firing. I've searched the web and the solution...
4
by: jehugaleahsa | last post by:
Hello: Is there a way to prevent one event from firing while another event is already being fired? I have a tool that extracts media from web pages and it has multiple events firing when the...
4
by: Joergen Bech | last post by:
I sometimes use delegates for broadcasting "StateChanged" events, i.e. if I have multiple forms and/or controls that need updating at the same time as the result of a change in a global/common...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...
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,...
0
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...

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.