<%@ WebHandler Language="C#" Class="CheckMember" %> using System; using System.Web; using System.Data; using System.Data.SqlClient; using System.Configuration; using Newtonsoft.Json; public class CheckMember : IHttpHandler { private string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; string id = context.Request.QueryString["id"]; if (string.IsNullOrEmpty(id)) { context.Response.Write("{\"error\":\"id parameter required\"}"); return; } try { using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); string query = "SELECT Bcdenroll, Ndbano, Mobile_1, F_name, L_name FROM Memberslist WHERE Bcdenroll = @id OR Ndbano = @id OR Mobile_1 = @id"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@id", id); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); context.Response.Write(JsonConvert.SerializeObject(dt)); } } catch (Exception ex) { context.Response.Write(JsonConvert.SerializeObject(new { error = ex.Message })); } } public bool IsReusable { get { return false; } } }