Avatar of grogo21
grogo21 asked on

Button onclick Event

Hello, I have sever buttons on my page.  Is it possible to point all of them to the same method but have them pass different values to the method like:

    Protected Sub LinkButtonClick(ByVal CatId As Integer)
           'Code
    End Sub

<html>
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButtonClick(1)"><%#Eval("SubCatName")%></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButtonClick(2)"><%#Eval("SubCatName")%></asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" OnClick="LinkButtonClick(3)"><%#Eval("SubCatName")%></asp:LinkButton>
</html>

I am getting error " 'AddressOf' operand must be the name of a method (without parentheses)." when I attempt to do what I have above.  

Thanks Very Much!
ASP.NETVisual Basic.NET

Avatar of undefined
Last Comment
ororiole

8/22/2022 - Mon
SOLUTION
Paulo Pimenta

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
grogo21

So I Need a subroutine which would call my custom function for every button?  The issue with that is that there will be a dynmic amount of buttons.  They are being created in a data repeater which selects a different amount of categories(1 category per button) each time.  Is there another way?

Thanks Very Much!
ASKER CERTIFIED SOLUTION
ororiole

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Your help has saved me hundreds of hours of internet surfing.
fblack61