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 6769537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:12:19+00:00 2026-05-26T15:12:19+00:00

This is my Default.aspx + jQuery Script: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN

  • 0

This is my Default.aspx + jQuery Script:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org
/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
Inherits="Sample001.Default" %>
<script src="jquery-1.6.4.min.js" type="text/javascript"></script>
<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="masterlbl" Text="Master" runat="server" />
                </td>
                <td>
                    <span class="Mastercs">
                <asp:DropDownList ID="ddl1" runat="server">
                <asp:ListItem Text="Item1" Value="Item1" />
                <asp:ListItem Text="Item2" Value="Item2" />
                <asp:ListItem Text="Item3" Value="Item3" />
                <asp:ListItem Text="Item4" Value="Item4" />
                <asp:ListItem Text="Item5" Value="Item5" />
                </asp:DropDownList>
                    </span>
                </td>
                <td>
            <asp:Label ID="slavelbl" Text="Slave" runat="server" />
            </td>
                <td>
                    <span class="slavecs">
                    <asp:DropDownList ID="ddl2" runat="server" />
                    </span>
                </td>
            </tr>
        </table>
    </div>
    </form>
    <script type="text/javascript">
        $(document).ready(function () {
            $('span.Mastercs select').change(function () {
                $.ajax({
                    type: "POST",
                    url: 'MyHandler.ashx',
                    dataType: "text",
                    data: "ItemSelected=" + $('select#ddl1').val(),
                    async: true,
                    success: function (data) { Handler_Success(data); }
                });
            });
            function Handler_Success(data) {
                $('select#ddl2').empty();
                $.each(data, function (i, slaveValue) {
$('select#ddl2').append($('<option></option>')
.val(data.Value).html(data.Text));
                });
            }
        });
    </script>
</body>
</html>

The above code work correctly.
But I need to pass one more parameter, and there is a problem.
I try This Way and also the following code, but retrieve null value:

$.ajax({
    type: "POST",
    url: 'MyHandler.ashx',
    dataType: "text",
    data: '{"ItemSelected=" ' + $('select#ddl1').val() + ', "ID="' + 
    $('select#ddl1').attr('id') + ' }',
    async: true,
    success: function (data) { Handler_Success(data); }
    });
});

Where is the problem?

Edit:

I also need to use HttpHandler rather WebService or WebMethod

this is my HttpHandler:

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

public class SlaveValueHandler : IHttpHandler {

    public bool IsReusable {
    get { return true; }
    }

        public void ProcessRequest(HttpContext context) {
            string valueSelected = context.Request["ItemSelected"];
            string id = context.Request["ID"];
            List<SlaveValue> slaveValues = new List<SlaveValue>();
            SlaveValue sv;
            sv = new SlaveValue();
            sv.Text = "SV1";
            sv.Value = valueSelected + id + "s1";
            slaveValues.Add(sv);
string responseText = Newtonsoft.Json.JsonConvert.SerializeObject(slaveValues);
context.Response.ContentType = "text/json";
context.Response.Write(responseText);
}
}

And My WebConfig:

<configuration>
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <handlers>
            <add name="Slave Handler" verb="*" path="MyHandler.ashx" 
type="Sample001.SlaveValueHandler,Sample001" preCondition="integratedMode" />
        </handlers>
    </system.webServer>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>

</configuration>

Edit:

I Find it here:
CodeProject

  • 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-26T15:12:20+00:00Added an answer on May 26, 2026 at 3:12 pm

    There is another way – using json2.js

    var postdata = new Object();
    postdata.parameter1 = <value>;
    postdata.parameter2 = <value>; 
    
    $.ajax({ 
    type: "POST", 
    url: 'MyHandler.ashx', 
    dataType: "application/json", 
    data: JSON.stringify(postdata), 
    async: true, 
    success: function (data) { Handler_Success(data); } 
    }); 
    }); 
    

    You are saved from formatting your JSON string everytime you add a new parameter. Make sure to read the it with the same name on the server side, else this wont work.

    JSON 2 is available here: https://github.com/douglascrockford/JSON-js/blob/master/json2.js

    Mark as answer if this worked for you

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

Sidebar

Related Questions

This is My Code Default.aspx: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd>
Here is my code <html xmlns=http://www.w3.org/1999/xhtml> <head runat=server> <title></title> <script type=text/javascript src=<%= ResolveUrl(Scripts/jquery-1.3.2.min.js) %>></script>
Here is my code: <%@ Page Language=C# AutoEventWireup=true CodeBehind=Default.aspx.cs Inherits=WebClient._Default %> <!DOCTYPE html PUBLIC
I am getting NetworkError: 500 Internal Server Error - http://localhost:5963/default.aspx/Call when am calling this
this is my link in my page asp:HyperLink ID=HyperLink1 runat=server NavigateUrl=~/Default.aspx>Add Record /asp:HyperLink with
Given this class public partial class Default : Page { private IRepository repo; ...
This is My Default.aspx: <body> <form id=form1 runat=server> <div class=Target> <label> First Object</label> <input
I read ScottGu's blog entry ( http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx ) a while back, and it seems
Let's say I have a template like this <script id=rowTemplate type=text/x-jquery-tmpl> <tr> <a href=${
Why doesn't this work? <script src=Scripts/jquery-1.3.2.js type=text/javascript></script> <script type=text/javascript> $(document).ready(function() { $('.myButton').click(); }); </script>

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.