how to call a c# webmethod on mouseover of linkbutton in

Total Post:104

 1697  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.

  1. Post:194

    Re: how to call a c# webmethod on mouseover of linkbutton in

    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() {
                contentType: "application/json; charset=utf-8",
                success:function(result) {
                    // Dosomething with records returned here
                    // Useresult.d to get to JSON data

      Modified On Apr-07-2018 01:52:17 AM



Enter your email address here always to be updated. We promise not to spam!