Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6853169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:28:46+00:00 2026-05-27T01:28:46+00:00

I have 2 DropDownList, like Master-Slave. This is my Default.aspx: <html xmlns=http://www.w3.org/1999/xhtml> <head runat=server>

  • 0

I have 2 DropDownList, like Master-Slave.
This is my Default.aspx:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
            <tr>
                <td>
            <asp:Label ID="MsLbl" runat="server" Text="Groups" />
                </td>
                <td>
            <asp:DropDownList ID="Masterddl" runat="server">
                    <asp:ListItem Text="G1" Value="G1" />
                    <asp:ListItem Text="G2" Value="G2" />
                    <asp:ListItem Text="G3" Value="G3" />
            </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
            <asp:Label ID="Svlbl" runat="server" Text="Members" />
            </td>
                <td>
            <asp:DropDownList ID="Slaveddl" runat="server" />
            </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

And this is my Script:

$(document).ready(function () {
$('select#Masterddl').change(function () {
    MasterChangeHandler($(this).val());
});

function MasterChangeHandler(Value) {
    $.ajax({
        type: 'Post',
        url: 'MasterSlaveHandler.ashx',
        dataType: "text",
        data: 'ItemSelected=' + Value,
        async: 'true',
        success: function (data) { SuccessHandler1(data); }

    });
}


function SuccessHandler1(data) {
    $('select#Slaveddl').empty();
    $.each(data, function (i, slaveValue) {
        $('select#Slaveddl').append(
    $('<option></option>').val(slaveValue.Value).html(slaveValue.Text)
    );
    });
}

And My Handler:

public class SlaveValues {
    public string Value { get; set; }
    public string Text { get; set; }
}


public class MasterSlaveDropDownListsHandler : IHttpHandler {
    public bool IsReusable {
        get { return true; }
    }

    public void ProcessRequest(HttpContext context) {
        string valueSelected = context.Request["ItemSelected"];
        List<SlaveValues> slaveValues = new List<SlaveValues>();
        SlaveValues sv;

        sv = new SlaveValues();
        sv.Text = "SV1";
        sv.Value = valueSelected + "s1";
        slaveValues.Add(sv);

        sv = new SlaveValues();
        sv.Text = "SV2";
        sv.Value = valueSelected + "s2";
        slaveValues.Add(sv);


        string responseText =
    Newtonsoft.Json.JsonConvert.SerializeObject(slaveValues);
        context.Response.ContentType = "text/json";
        context.Response.Write(responseText);
    }
}

but there is nothing to append.
Also I see the response in firebug windows as following(when I Select G2 from Master ddl):

[{"Value":"G2s1","Text":"SV1"},{"Value":"G2s2","Text":"SV2"}]

and finally I change my success method of script with this new one for test:

function SuccessHandler2(data) {
    $('select#Slaveddl').empty();
    $.each(data, function (i, slaveValue) {
        $('select#Slaveddl').append(
    $('<option></option>').val('Member' + i).html('Member' + i)
    );
    });
}

when try this new script the binding to Slave ddl work correctly but with some additional items : the index show member0 to member30 and I don’ know why.

Edit1:
I also try this one and append correctly:

function SuccessHandler3(data) {
var values = [{ "Value": "G2s1", "Text": "SV1" }, { "Value": "G2s2", "Text": "SV2"}];
        $('select#Slaveddl').empty();
        $.each(values, function (i, slaveValue) {
            $('select#Slaveddl').append(
$('<option></option>').val('Member' + slaveValue.Value).html('Member' +
 slaveValue.Text)
        );
        });
    }

So I think there is a problem with manipulate of return value (data).

for more specific view the following pic is the JSON tab in firebug windows when I select G3 in Master ddl:

JSON Tab in firebug

Edit2:

Also I try this one and just the first alert appear, apparently the (data.d) is null or unknown object:

function SuccessHandler6(data) {
    var selection = $('select#Slaveddl');
    $(selection).children().remove();
    alert('in handler and remove children correctly');
    if (data.d) {
        alert('data.d is not null');
        $(data.d).each(function (index, item) {

$(selection).append('<option>').val(item.Value).html(item.Text);
            alert('after append in index: ' + index);
        });
    }
}

How can I use return value correctly and append to Slave ddl? Where is the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:28:47+00:00Added an answer on May 27, 2026 at 1:28 am

    Maybe this can be useful this very like as your problem an have a complete step by step solution:

    use return value of json in jquery

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dropdownlist in my asp.net MVC2 view like this: <% using(Html.BeginForm(temp,Settings)){ %>
I have a DropDownList in my aspx file like this: <asp:DropDownList runat=server ID=MaxRec> <asp:ListItem>10</asp:ListItem>
I have a dropdownlist that looks like this: @Html.DropDownListFor( x => x.Attribute.AttributeID, new SelectList(Model.Attributes,
When I have a DropDownList that relevant to Model of view like this: @Html.DropDownListFor(model
I have the dropdown list like this <?php echo $form->dropdownList($customers,'customer_name', CHtml::listData(Customers::model()->findAll(), 'id', 'customer_name'), array(
hi I have this gridview like this. <asp:DropDownList ID=triggerDropDown runat=server AutoPostBack=true onselectedindexchanged=triggerDropDown_SelectedIndexChanged> <asp:GridView ID=myGridView
I have the dropdownlist like this one : <asp:dropdownlist ID =ddlgender runat=server> <asp:ListItem Text=--Please
I have a dictionary that looks like this Dictionary<string,string[]> I also have 2 dropdownlist.
I have a dropdownlist like this <asp:dropdownlist runat=server autopostback=true onselecteditemindexchanged=fire_event ID=DDL/> and on codebehind
I have a dropdownlist : <%=Html.DropDownList(memberInvoiceStatus, ViewData[memberInvoiceStatus] as SelectList)%> Can I set the default

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.