locked
How to create dynamic event handler in ASP .NET using VB RRS feed

  • Question

  • User-1030184309 posted

    I want to create a button dynamically and onclick event for the button.

    Require syntax to create dynamic event handler in ASP .NET using VB

    Wednesday, November 9, 2011 12:35 AM

Answers

  • User-68639941 posted
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    		Dim btn As New Button
    		btn.Text = "Dynamic Button"
    		AddHandler btn.Click, AddressOf btn_Click
    		form1.Controls.Add(btn)
    	End Sub
    	Protected Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    		Response.Write("Dynamic Event")
    	End Sub
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 9, 2011 1:19 AM