Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Dynamically Created Controls in VS2005 ASP.NET 2.0

Reply
Thread Tools

Dynamically Created Controls in VS2005 ASP.NET 2.0

 
 
Amelyan
Guest
Posts: n/a
 
      11-03-2005
My standard dynamically created controls (e.g. Button, RadioButton, etc.)
stopped firing event assigned to them in VS2005 (final release) ASP.NET 2.0.
Is anyone else having the same problem?

I guess a better help would be for someone to recommend a proper way of
dynamically creating a control on the
page and having it fire event when form is submitted in ASP.NET 2.0. Maybe
a simple example.

Thanks,


 
Reply With Quote
 
 
 
 
Amelyan
Guest
Posts: n/a
 
      11-04-2005
I *finally* narrowed down my problem to my custom web control. If I hookup
event inside dynamically created custom web control, it doesn't get fired.
However, event gets fired for any other standard dynamically created web
control. the code below works in VS 2003 (radio_CheckedChanged get
invoked), but it doesn't work in VS 2005.

Is there something extra I need to override or add in VS2005 to make event
fire?


namespace ClassLibrary1

{

[DefaultProperty("Text")]

[ToolboxData("<{0}:WebCustomControl1
runat=server></{0}:WebCustomControl1>")]

public class WebCustomControl1 : WebControl

{

[Bindable(true)]

[Category("Appearance")]

[DefaultValue("")]

[Localizable(true)]

public string Text

{

get

{

String s = (String)ViewState["Text"];

return ((s == null) ? String.Empty : s);

}

set

{

ViewState["Text"] = value;

}

}

protected override void RenderContents(HtmlTextWriter output)

{

base.RenderContents(output);

}

protected override void CreateChildControls()

{

Controls.Add(GetRadioButton());

}

public Control GetRadioButton()

{

TableCell cell = new TableCell();

RadioButton radio = new RadioButton();

radio.ID = "a_12311";

radio.CheckedChanged += new EventHandler(radio_CheckedChanged);

radio.Text = "Suka!!!!!";

radio.GroupName = "sadlfjklsakdjfas";

radio.Checked = false;

cell.Controls.Add(radio);

Table tbl = new Table();

tbl.Rows[tbl.Rows.Add(new TableRow())].Cells.Add(cell);

tbl.BorderWidth = 10;

return tbl;

}

void radio_CheckedChanged(object sender, EventArgs e)

{

throw new Exception("The method or operation is not implemented.");

}

}

}

"Amelyan" <bamelyan at wi.rr.com> wrote in message
news:(E-Mail Removed)...
> My standard dynamically created controls (e.g. Button, RadioButton, etc.)
> stopped firing event assigned to them in VS2005 (final release) ASP.NET
> 2.0. Is anyone else having the same problem?
>
> I guess a better help would be for someone to recommend a proper way of
> dynamically creating a control on the
> page and having it fire event when form is submitted in ASP.NET 2.0.
> Maybe a simple example.
>
> Thanks,
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
Events not fired for Dynamically Created Controls in VS2005 ASP.NET 2.0 Richard Huang ASP .Net Web Controls 1 01-09-2006 03:16 AM
Managing ViewState of a dynamically created Custom Composite Server Control -(where the original is also dynamically created) dickster ASP .Net Building Controls 0 12-08-2005 09:32 AM
VS2005 ASP.NET 2.0 does not fire event for dynamically created custom web controls Amelyan ASP .Net 2 11-05-2005 05:29 PM
retrieving values from controls dynamically created in a <asp:table> Bryan Donaldson ASP .Net 0 11-24-2003 06:29 PM



Advertisments