473,508 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Event on Dynamic Control - ASP

Hello,

I've created a dynamic button and checkbox and i want to create an event for
each one of them.
altough i've created the event and assigned them to each control, nothing
happens,
the event is not occurring.
What am i doing wrong?

this is my code for the checkBox:
CheckBox cb = new CheckBox();

cb.Text = "Text";
cb.Font.Bold = true;
cb.ID = "Friend_cb";
cb.Font.Name = "Tahoma";
cb.Font.Size = new FontUnit("16pt");
cb.ForeColor = Color.Blue;
cb.Checked = false;
cb.CheckedChanged += new System.EventHandler(Show_OutSide_TextBox);
cb.EnableViewState = true;
this.form1.Controls.Add(cb);

private void Show_OutSide_TextBox(object sender, System.EventArgs e)
{
if (((CheckBox)sender).Checked == true)
{
Create_Label(0, "<br><br>");
Create_OutSide_Player_TextBox();
}
}

Thanks,
Gidi
Sep 17 '07 #1
3 3032
Hi,
As far as my understanding goes if you are creating dynamic controls then
you need to recreate same controls on postback and also give them same ID as
previously given before postback
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Gidi" wrote:
Hello,

I've created a dynamic button and checkbox and i want to create an event for
each one of them.
altough i've created the event and assigned them to each control, nothing
happens,
the event is not occurring.
What am i doing wrong?

this is my code for the checkBox:
CheckBox cb = new CheckBox();

cb.Text = "Text";
cb.Font.Bold = true;
cb.ID = "Friend_cb";
cb.Font.Name = "Tahoma";
cb.Font.Size = new FontUnit("16pt");
cb.ForeColor = Color.Blue;
cb.Checked = false;
cb.CheckedChanged += new System.EventHandler(Show_OutSide_TextBox);
cb.EnableViewState = true;
this.form1.Controls.Add(cb);

private void Show_OutSide_TextBox(object sender, System.EventArgs e)
{
if (((CheckBox)sender).Checked == true)
{
Create_Label(0, "<br><br>");
Create_OutSide_Player_TextBox();
}
}

Thanks,
Gidi
Sep 17 '07 #2
Hi,
Thanks For the quick reply.

I tried to add the folowing code to my Page_Load()
if (this.IsPostBack)
{
Create_OutSide_Player_CheckBox();
return;
}

and still nothing happens.

"Manish Bafna" wrote:
Hi,
As far as my understanding goes if you are creating dynamic controls then
you need to recreate same controls on postback and also give them same ID as
previously given before postback
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Gidi" wrote:
Hello,

I've created a dynamic button and checkbox and i want to create an event for
each one of them.
altough i've created the event and assigned them to each control, nothing
happens,
the event is not occurring.
What am i doing wrong?

this is my code for the checkBox:
CheckBox cb = new CheckBox();

cb.Text = "Text";
cb.Font.Bold = true;
cb.ID = "Friend_cb";
cb.Font.Name = "Tahoma";
cb.Font.Size = new FontUnit("16pt");
cb.ForeColor = Color.Blue;
cb.Checked = false;
cb.CheckedChanged += new System.EventHandler(Show_OutSide_TextBox);
cb.EnableViewState = true;
this.form1.Controls.Add(cb);

private void Show_OutSide_TextBox(object sender, System.EventArgs e)
{
if (((CheckBox)sender).Checked == true)
{
Create_Label(0, "<br><br>");
Create_OutSide_Player_TextBox();
}
}

Thanks,
Gidi
Sep 17 '07 #3
On Sep 17, 6:06 am, Gidi <shna...@hotmail.com.dontspamwrote:
I tried to add the folowing code to my Page_Load()
if (this.IsPostBack)
{
Create_OutSide_Player_CheckBox();
return;
}

and still nothing happens.

Page_Load is too late. You should do that in Init.
Sep 17 '07 #4

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

Similar topics

8
7886
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
7
1587
by: Rob | last post by:
I need a way to determine the name of the control that called an event. I have tested many different code variations but none seem to work. The one that makes the most sense to me is below, but it...
5
19645
by: RA | last post by:
I have created a button dynamically; which has been added to a TableCell of a TableRow of a Table control. Is there a way to add onclick event which calls a procedure on the Server-side itself....
1
1254
by: Adrian Parker | last post by:
At postback time, the controls are all recreated before an event fires. If the event determines that some of the controls need to be replaced with different controls that you can't create as...
15
26486
by: Amit D.Shinde | last post by:
I am adding a new picturebox control at runtime on the form How can i create click event handler for this control Amit Shinde
2
3815
by: Developer_Software | last post by:
Thanks in advance to anyone who can help :) I've got a placeholder control WITHIN A USER CONTROL that has its contents dynamically added and removed at runtime by a regular .aspx page. At...
9
14420
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it...
5
3065
by: Andrew Robinson | last post by:
I have a page that can load a number of different user controls. Each of these user controls inherits from a common base class and the controls are loaded based on application state, status, etc...
1
4638
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
3467
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
0
7229
marktang
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,...
0
7129
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
7333
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5057
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...
0
4716
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...
0
3208
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...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1566
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 ...

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.