Loading ...

how to add an event handler at runtime?

Who is online?  0 guests and 0 members
home  »  forums   »  asp.net topics   »  client side web development   » how to add an event handler at runtime?

how to add an event handler at runtime?

Posts under the topic: how to add an event handler at runtime?

Posted: 5/31/2011

Lurker 245  points  Lurker
  • Joined on: 4/15/2011
  • Posts: 44

I have created a panel with some text boxes on it & a button at code behind in c#.net

becoz I want to add that panel multiple times

user will enter values to those textboxes & click the submit button

I want to add event handler to that button

Please help me out...

 

 


Posted: 5/31/2011

Professional 8505  points  Professional
  • Joined on: 5/3/2010
  • Posts: 391
  Answered

Hi pallavi,

Can you show us your code?

Maybe you can accomplish this very easily with anonymous functions, like this:

button1.Click += delegate
{
 Response.Write("Hellow from here");
}

Hope this helps.

Regards,
Hajan


Posted: 6/1/2011

Lurker 245  points  Lurker
  • Joined on: 4/15/2011
  • Posts: 44

Hi Hajan,

Thanks for the reply

I have 3 linkbuttons as Add Current Professional Info, Add Past professional Info, Add more...

on the click event of all these buttons i am calling AddPanel() method in which i have created some lables,textboxses,button

 code to add button:-   Button btnsubmit =new Button;

                                     btnsubmit.Text= "Submit";

                                     btnsubmit.Click +=new EventHandler(btnsubmit_Click);

private Void btnsubmit_Click(Object sender,EventArgs e)

{

      lblmessage.Text= "Hello";

}

but when i click submit button it's not showing me hello message

 

 


Posted: 6/16/2011

Professional 8505  points  Professional
  • Joined on: 5/3/2010
  • Posts: 391
  Answered
Page 1 of 1 (4 items)