Reputation: 9555
On my master page I have a telerek radmenu called "myMenu" than looks like this:
on my aspx page that uses the master page I am trying to alter the link on the button "door" but the following wont work. Can you please help
Protected Sub Page_Load()
Dim H As RadMenu = DirectCast(myMenu.FindControl("House"), RadMenu)
Dim D As RadMenuItem = DirectCast(H.FindControl("door"), RadMenuItem)
D.click = LoadStuff()
End Sub
Private Sub LoadStuff()
'update something in vb.net
End Sub
Upvotes: 0
Views: 631
Reputation: 101
You have a few options. First, I'll answer the question exactly as you asked. In this case, you need to use AddHandler which is similar to using the += in c# for assigning event handlers.
Protected Sub Page_Load()
Dim H As RadMenu = DirectCast(myMenu.FindControl("House"), RadMenu)
Dim D As RadMenuItem = DirectCast(H.FindControl("door"), RadMenuItem)
AddHandler D.Click, AddressOf LoadStuff
End Sub
Private Sub LoadStuff(sender As Object, e As EventArgs)
'update something in vb.net
End Sub
However, if you're not creating your menu in code, and it's already built at design time, why not just use the following:
Protected Sub Page_Load()
End Sub
Private Sub door_Click(sender As Object, e As EventArgs) Handles door.Click
'update something in vb.net
End Sub
Upvotes: 1