how to create an asp button dynamically and add event to it

前端 未结 5 1413
予麋鹿
予麋鹿 2021-01-21 07:06

I\'m trying to create a button dynamically on asp.net,but I can\'t add the event to it.What is wrong or missing below?

Thanks in advance

$

         


        
5条回答
  •  长情又很酷
    2021-01-21 08:06

    read the article about the asp.net webforms life-cycle http://msdn.microsoft.com/en-us/library/ms178472.aspx. you have to create/recreate your controls everytime when loading the page (e.g. OnLoad-Method)

    http://www.asp.net/web-forms/videos/aspnet-ajax/how-to-dynamically-add-controls-to-a-web-page

提交回复
热议问题