In this article we will explain how to call page method using jQuery ajax example or jQuery ajax call page method with example or page method using jQuery ajax with example or jQuery ajax bind dropdownlist using page method with example.


Here we will learn how to call  page method using jQuery ajax with dropdownlist binding from server side in c# web page, so write the following code in your aspx page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="TutorialsAsp.Net.WebForm1" %>
<!DOCTYPE html>
<html xmlns="">
<head runat="server">
    <title>Bind Dropdownlist with JQuery in</title>
    <script type="text/javascript" src="">
    <script type="text/javascript">
        $(document).ready(function () {
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "WebForm1.aspx/BindDatatoDropdown",
                data: "{}",
                dataType: "json",
                success: function (data) {
                    result =$.parseJSON(data.d);
                    for (i = 0; i <result.length; i++) {
                error: function (result) {
    <form id="form1" runat="server">
        <h3>Bind Dropdownlist with JQuery in</h3>
           <asp:DropDownList ID="ddlUser" runat="server" ClientIDMode="Static" />


Now open code behind file and add following below code:

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace TutorialsAsp.Net
    public partial class WebForm1 : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
        public static string BindDatatoDropdown()
            DataTable dt = new DataTable();
            dt.Columns.Add("UserId", typeof(Int32));
            dt.Columns.Add("UserName", typeof(string));
            dt.Rows.Add(1, "Satinder Singh");
            dt.Rows.Add(2, "Amit Sarna");
            dt.Rows.Add(3, "Andrea Ely");
            dt.Rows.Add(4, "Leslie Mac");
            dt.Rows.Add(5, "Vaibhav Adhyapak");
            string JSONresult = JSONresult = JsonConvert.SerializeObject(dt);
            return JSONresult;

in above example we are calling [Web Method] in page using jQuery ajax method. Now run your application and check the output that would be like this

How to Call ASP.Net Page Method using jQuery AJAX Example

I hope it will help to you.


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like