Create runtime button in

Abstract :

This Code demonstrates how to add button and its events dynamically.

Here's the Code

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Adding a Runtime control
Dim button1 As New System.Web.UI.WebControls.Button
AddHandler button1.Click, New EventHandler(AddressOf button1_Click)

End Sub

Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Write("HI i clicked")
End Sub


Author: Deepika Haridas08 Jul 2009 Member Level: Gold   Points : 2


I made some changes. Reduced points as it was not formatted . Use proper titles and place your code within "CODE" tags.

Thanks & Regards,

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: