---
title: "how to call a c# webmethod on mouseover of linkbutton in asp.net?"  
description: "how to call a c# webmethod on mouseover of linkbutton in asp.net?"  
author: "marcel ethan"  
published: 2014-12-02  
updated: 2014-12-03  
canonical: https://www.mindstick.com/forum/12733/how-to-call-a-c-sharp-webmethod-on-mouseover-of-linkbutton-in-asp-dot-net  
category: "asp.net"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# how to call a c# webmethod on mouseover of linkbutton in asp.net?

Is it possible to call a c# webmethod on mouseover on [Linkbutton](https://www.mindstick.com/forum/2100/linkbutton-to-expand-gridview-causes-row-colors-from-function-to-be-lost) ? what i want is to call a webmethod in which i am [binding](https://www.mindstick.com/blog/146/dynamic-binding-in-c-sharp) a [repeater](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control) 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](https://www.mindstick.com/forum/172/how-v-insert-data-into-table-and-display-into-gridview-in-aspx-cs-file-with-out-using-wizard):**

```
[System.Web.Script.Services.ScriptMethod()][System.Web.Services.WebMethod]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](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) [autocomplete](https://www.mindstick.com/forum/156169/what-is-google-suggest-or-autocomplete) extender but it has a propperty of calling a webmethod but is it so in this case also? Thank you.

## Replies

### Reply by Anonymous User

Use ASP.NET AJAX Page Methods, like this:

```
[WebMethod]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() {        $.ajax({            type:"POST",            url:"PageName.aspx/GetRecords",            data:"{}",           
contentType: "application/json; charset=utf-8",            dataType:"json",            success:function(result) {                // Dosomething with records returned here                // Useresult.d to get to JSON data            }        });    });});
```


---

Original Source: https://www.mindstick.com/forum/12733/how-to-call-a-c-sharp-webmethod-on-mouseover-of-linkbutton-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
