CasCading DropDownList using Generic Handler and JQuery in

Category: ASP.NETGENERIC HANDLERJQUERY Comments: 2 comments

Sometimes we need to do fill dropdownlist using JQuery and Generic Handler in

Explanation given below:

Design Page:

<asp:DropDownList ID=”ddlState” runat=”server” OnPreRender=”ddlState_PreRender”
<asp:ListItem Value=”0″>SELECT YOUR STATE</asp:ListItem>
<asp:DropDownList ID=”ddlProduct” runat=”server”

Generic Handler:

public void ProcessRequest(HttpContext context)

context.Response.ContentType = “application/json”;
int id = Convert.ToInt32(context.Request["id"]);
string sJSON = GetProduct(id);
public string GetProduct(int id)

ProductController objPrductCont = new ProductController();//My Class Name

//GetProductsByStateID(id) = It will Give All Record On The Basis Of ID

List<ProductInfo> objProduct = objPrductCont.GetProductsByStateID(id);

//Converting Object into JSON
System.Web.Script.Serialization.JavaScriptSerializer oSerializer =
new System.Web.Script.Serialization.JavaScriptSerializer();
string sJSON = oSerializer.Serialize(objProduct);
return sJSON;

JQuery Script:

$(“select[id$=ddlState]“).change(function () {

var statVal = $(“select[id$=ddlState]“).val();
if (statVal != “SELECT YOUR STATE”) {

var id = statVal = $(“select[id$=ddlState]“).val();// You will get the value of selected item

$.post(“/CallHandler.ashx”, { id: id }, function (result) {
$(“select[id$=ddlProduct]“).attr(“style”, “cursor:default”);
$(“select[id$=ddlProduct]“).append($(“<option></option>”).val(0).html(“SELECT YOUR PRODUCT”));
$(result).each(function (i) {


else {
$(“select[id$=ddlProduct]“).append($(“<option></option>”).val(0).html(“SELECT YOUR PRODUCT”));
$(“select[id$=ddlProduct]“).attr(“disabled”, “disabled”);
return false;



2 comments on “CasCading DropDownList using Generic Handler and JQuery in

  1. Asif Khan on said:

    Can you send me your code

Leave a Reply

Your email address will not be published. Required fields are marked *


HTML tags are not allowed.