[thelist] ASP.NET: Passing the value of a link button
Peter Brunone (EasyListBox.com)
peter at easylistbox.com
Tue Aug 8 11:49:31 CDT 2006
> Yup, I went back and looked at the post where you mentioned this. I'm
> just unclear on the exact syntax:
Oh, that. I guess I could have been a bit more clear, eh :)
Public Sub AlphaCommand(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim lbTemp As LinkButton = sender
Dim strCatLetter As String = lbTemp.Text
' or whatever property you need
End Sub
I believe you can actually access the properties directly in the sender if you aren't using Option Strict -- implicit limiting conversions are allowed, or so I recall -- but this way should save you the trouble of finding out if that is the case.
HTH,
Peter
From: "Casey Crookston" caseyc at IntelliSoftmn.com
PETER:
I think I already answered that... just use Sender.Property to get
whatever properties you need from the sender (control that triggered the
event).
CASEY:
Yup, I went back and looked at the post where you mentioned this. I'm
just unclear on the exact syntax:
Public Sub AlphaCommand(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim strCatLetter As String = sender.?????????
End Sub
The only popup option that Visual Studio gives me at sender. is GetType
PETER:
So what was the solution for the untouched subroutine?
CASEY:
Because the linkbutton controls are dynamic they need to be created in
each page cycle. I added populateAlpha() to the pageload and it
worked.
Private Sub populateAlpha()
Dim i As Integer
For i = 65 To 90
Dim lbAlpha As LinkButton = New LinkButton
lbAlpha.Text = "&#" & i & "; "
lbAlpha.CssClass = "alpha_link"
lbAlpha.ID = "lbAlpha" & i
AddHandler lbAlpha.Click, New EventHandler(AddressOf AlphaCommand)
plhAlpha.Controls.Add(lbAlpha)
Next
End Sub
Thanks for all the help!
More information about the thelist
mailing list