Home > DeveloperSection > Forums > how to call a c# webmethod on mouseover of linkbutton in asp.net?
marcel ethan
marcel ethan

Total Post:105

Posted on    December-02-2014 10:26 PM

 ASP.Net C# 

 1 Reply(s)
 978  View(s)
Rate this:

Is it possible to call a c# webmethod on mouseover on Linkbutton ? what i want is to call a webmethod in which i am binding a repeater control with datatable. How? in aspx:


<asp:LinkButton Text='<%#Eval("SNA")%>' ID="lnkpro1" runat="server"

CssClass="linkbutton" servicemethod="GetRecords"

OnClick="btn_Click1" CommandArgument='<%# Eval("Sets") %>'></asp:LinkButton>

in aspx.cs:




public void GetRecords(object sender, EventArgs e)




I am not getting the point that is how is it possible to call a webmethod on linkbutton mouseover. I have used a webmethod in textbox autocomplete extender but it has a propperty of calling a webmethod but is it so in this case also? Thank you.

Kamlakar Singh
Kamlakar Singh

Total Post:194

Posted on    December-03-2014 6:52 AM

Use ASP.NET AJAX Page Methods, like this:



public static List<Record> GetRecords()


    // Go to database to get list of records

    List<Record> listOfRecords = GetRecordsFromDatabase();


    return listOfRecords;


I made up the Record class here. A list of something needs to be returned, so I made it up for the example's sake.

Now you can call the ASP.NET AJAX Page Method, like this:


$(document).ready(function() {

    $('.linkbutton').mouseover(function() {


            type: "POST",

            url: "PageName.aspx/GetRecords",

            data: "{}",

            contentType: "application/json; charset=utf-8",

            dataType: "json",

            success: function(result) {

                // Do something with records returned here

                // Use result.d to get to JSON data





Don't want to miss updates? Please click the below button!

Follow MindStick