Search code examples
asp.netlinkbutton

Please check my code to add linkbutton and click event programmatcally in asp.net


i wrote following code to create a linkbutton programmatically, but its showing like lable at runtime not as link

Dim lnkbutton As LinkButton = New LinkButton()
lnkbutton.ID = "HostelsClub" & dr("dshotelid").ToString()
lnkbutton.Text = "HostelsClub"
lnkbutton.PostBackUrl = Request.Url.ToString()

lnkbutton.ToolTip = "Click here To Book"
AddHandler lnkbutton.Click, AddressOf lnkBook_Click
PHbook.Controls.Add(lnkbutton)

Solution

  • problem is not with your link button you need to add event handler for link button in page's init function .. than only it will work..