events in run time not work

R

Roberto

Hi, i´ve a problem creating a button & asociating a method whith the click
event. i´ve this code:

{....
Button b=new Button();
b.CausesValidation=false;
b.Click+=new EventHandler(b_Click);
.....}

private void b_Click(object sender, System.EventArgs e)
{
Label1.Text="hola "+((Button)sender).ID;
}

And runin the web aplication, whith the debugger. The button is created, and
i click on it, and the method b_Click start to execute, there are not
problems, and finish the ejecution of the click, but the label text has not
changed!
It supose that is doing it, but does´nt work.

Pleasse someone could help me? If you don´t understund the problem, pleasse
tell me and i´ll explain another time.

Thanks very much.
 
T

Teemu Keiski

Hi,

Ia ssume that you are creating Button vontrol dynamically.

Check that:

a) You create dynamic control on every request
b) You create the control at Page_Load at the latest (for events to work)
c) With Response.Write("Test") statement or something that does the method
run at all (I suspect it doesn't run at all)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,139
Messages
2,570,807
Members
47,356
Latest member
Tommyhotly

Latest Threads

Top