Link to home
Create AccountLog in
Avatar of Latitudes
Latitudes

asked on

Call function in C# codebehind from an <a> link

On page load, I have to create a new link (ex. <a>Test</a>), but this link needs to call a function in the c# codebehind (ex. void Test_Click(Object sender, CommandEventArgs e) ).

How would I go about doing this?

Thanks in advance.
Avatar of Robert Schutt
Robert Schutt
Flag of Netherlands image

Have you tried a LinkButton? This renders as an <a> tag but does a postback so you can define a Click event on it in your code-behind.
Avatar of Latitudes
Latitudes

ASKER

I was hoping to go about it a different way.  I'm trying to implement infinite scroll on a listview.  Is there any way to append rows to the listview control?
Meaning I'm calling a [WebMethod] and I don't think it's possible to return a LinkButton or another object.
Hmm, ok that's totally different from what I read initially. I think you want to call another page to return results and then add those with a jQuery call for example? I'll have to try it out myself. Good starting point for me is usually looking at the generated html (as opposed to the aspx).
ASKER CERTIFIED SOLUTION
Avatar of Robert Schutt
Robert Schutt
Flag of Netherlands image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Thanks for your help on this.  Unfortunately, the situation I have is a lot more complicated because of the extensive ondatabound events in my Listview.  If possible, I'd rather not have to recreate everything twice.  I'm going to accept your answer and post a new message.

Thanks again!