.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

MVC Json and Jquery with dropdownlist

Posted By:      Posted Date: September 28, 2010    Points: 0   Category :ASP.Net

 Dear all,

I want to do like below:

I have three dropdownlist:

- test

- test1

- test2

and i have two textbox

 - txtname

- txtsex

when i click on test dropdown list i want to diplay data in test1 dropdownlist and display in txtname and txtsex too, how can i do by using mvc json and jquery ?

View Complete Post

More Related Resource Links

jquery ajax - bind json to dropdownlist


I'm using jquery ajax to populate a dropdown list to avoid page refresh via a webmethod.

My webmethod returns a json string. My question is how can i bind this to my asp.net dropdownlist?

See below for jquery code:

function getTeamid() {
        var teamid = $(".ccTeam").val();            
            type: "POST",
            url: "NewJob.aspx/sayHello",
            data: "{val:" + teamid + "}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                error: AjaxFailed


    function AjaxSucceeded(result) {
    function AjaxFailed(result) {
          alert(result.status + ' ' + result.statusText);

See below for webmethod code:

        public static string sayHello(string val)
            DataTable dt = dbTeam.getJobTypesByTeamid(val);
            return Intranet.Core.Util.GetJSONString(dt);            


jQuery: Styling DropDownList Alternating Items (Rows)

In the following example, I will show how you can style any asp:dropdownlist very easily.

The example demonstrates how you can change alternating row items background color, using the fadeTo() to add a nice touch in the dropdownlist. You can change alt rows with a couple lines.

Writing Data to database with jQuery Forms, ASMX Webservice, & JSON - help!



Can someone point me in the right direction on how to submit data from a jQuery form to a ASMX webservice? I have gotten everything on the form ready to be submitted to the database and now I am stuck on how to send it over using $.ajax(). Everything I have read tells me how to get data from a webservice and display it with jQuery, but not the other direction nor how to access the json data within the within the webservice service(similar to a Request.Form approach with ASP.NET forms).

In other words: 

1. What do I need to do to my webservice to make sure it can receive data from the jQuery form. 

2. What do I need to do in jQuery to receive an acknowledgement the save on the server side was successful. 

I can explain more if need be, but if there is a comprehensive tutorial on not only reading, but also WRITING data with jQuery, JSON, etc. I would love to get pointed in that direction. 

jQuery UI Autocomplete, Web Services and JSON

Hi guys, this is my first post, I´m desperate after wasting 2 days in google and reading forums ans sites. I can´t make it work. I just want to provide the name of cities to show in the autocomplete plugin. Let´s go part by part:WEB SERVICE: I use the Json.Net component to serialize a datasetpublic string ConsultTable(string data) { SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["SqlServerConnection"].ToString()); SqlCommand command = new SqlCommand("SELECT name FROM cities",connection); connection.Open(); DataSet dataset = ToDataSet(command.ExecuteReader()); Newtonsoft.Json.JsonSerializer json = new Newtonsoft.Json.JsonSerializer(); json.NullValueHandling = NullValueHandling.Ignore; json.ObjectCreationHandling = Newtonsoft.Json.ObjectCreationHandling.Replace; json.MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore; json.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; json.Converters.Add(new DataSetConverter()); StringWriter sw = new StringWriter(); Newtonsoft.Json.JsonTextWriter writer = new JsonTextWriter(sw); writer.Formatting = Formatting.None; writer.QuoteChar = '"'; json.Se

Can I write a wcf endpoint to communicate with JSON from Jquery on page?

Hi Guys,I need to be able to expose information to a page, and I need to write the information in xml on my webserver which will be dynamically created from the database. I need to use json to pass the data from the screen back to the server two way communication xms back and forth. Is it actually any good using a wcf endpoint to serve the json back to the page and use query with wcf? Is this possible?Or is it easier to use standard pages .aspx and just do a call to a url and get the json with jquery....We will probably want to send this information to other locations at some point in the future too....Cheers,Pete

Get dropdownlist event OnSelectedIndexChange using jquery

I have dropdownlist that located inside a repeater, how can i get OnSelectedIndexChange event of this dropdownlist? i want to use this event to set TextBox value olso inside this repeater, i try this code$("#Table1> tbody > tr ").each(function() { var rowId = $(this).attr("id"); $(this).find("td > #DropDownList1").change(function() { $("#" + rowId + "> TD:nth-child(6) > input[name$='TextBox1']").val("Test"); }); }); But did not work, can anyone please help me?

JQuery with dynamic ASP.NET controls (DropDownList)

I am mixing JQuery with ASP.NET webforms.  Adding dynamic controls and accessing the selected values with JQuery works differently under different circumstances and I am trying to establish the difference. Why does Senario 1 work in debug mode but not without breakpoints?  What does databinding to a GridView do that adding DropDownList controls to a asp:panel does not? Is there some sort of DOM registration going on in DataBind? All senarios use the same JQuery: var ddlCollection = $("select[name$='ddlDynamicDropDown']") Senario 1: Breakpoints on each line (Success) Add DropDownList controls to a asp:panel dynamically in the PageLoad method (Does the page lifecycle matter? OnLoad method instead?). Run the code Select values and click on a button firing a JavaScript function (Break in Debug) Break in JavaScript file Access the dropdowns and their selected values successfully Senario 2:  Run the Senario 1 code without breakpoints (Fails to locate the ddlCollection) Senario 3: Use a GridView (Success) Add values to populate the DropDownList controls to a Generic List. Bind the values to a GridView control containing the DropDownList controls Run the code Select values and click on a button firing a JavaScript function Use JQuery to Access the dropdowns and their selected values successfully.  

set selected value after jQuery populated Dropdownlist



i'm using jQuery to populate an cascading dropdownlist. But i want to set a selected item after jQuery filled the DDL with items.

How do i do that?


how to save and retrive date in database using jquery ajex asp.net ,JSOn,XML,HTML


how to save and retrive  date in database using  jquery ajex asp.net ,JSOn,XML

jQuery - DropDownList and Textbox in DataList



I am using Dropdown Lists with Textbox in DataList Control.

I want to Enable disable Textbox depending on the Value selected in the Dropdownlist using jQuery.

Thanks for the Help.



jquery ajax json



I've finally got my dropdowns populating via jquery,ajax and json (via page methods). It works fine, until I submit the page I get error shown below. What's the best way of fixing this?

Part of me is tempted to just install asp.net ajax/update panels and use this, however, I really want to avoid this as I want to stick with jquery ajax and json especially as I've spent time learning this. thanks.

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. 


Accessing JSON Data From an ASP.NET Page Using jQuery


I am trying to load the JSON data that I am getting from an aspx page into a drop down list that I have on another page but I am getting the following javascript error.

Microsoft JScript runtime error: 'SiteID' is null or not an object

The SiteID is not returning null though and I believe that is an object. The following is the code I am using to try and load the data into the drop down list:

$.getJSON('Test.aspx?DepotID=' + DepotID, function (sites) {
                        $.each(sites, function (index, elem) {

how to save data with jquery using json


a page contain

<table id="Grid_Event1" cellspacing="0" rules="all" border="1" style="font-family:verdana;font-size:11px;border-collapse:collapse;">

							<th scope="col">OWNER</th><th scope="col">FORMCODE</th><th scope="col">ID</th><th scope="col">COMPANY</th>


how to save every row in database using jquery json

jquery json google ws api

i am trying to get the google json from my local host

and i getting: Line: 4984 Error: Access is denied. from the jquery
what is missing?? 

well this is the code
<script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" charset="utf-8">
    $(document).ready(function () {
        var _url = 'https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=fuzzy%20monkey';
        var _serverParam = "";

        $.getJSON(_url, _serverParam, theCallBack);

        function theCallBack(theData, theStatus) {
            alert(theData); alert(theStatus);



ASP.NET: AJAX Cascading Dropdownlist with Autosuggest using Jquery

This article explains with an example on how to implement cascading dropdownlist using jquery and apply autocomplete feature using Select2 jquery plugin in the client side.

Post JSON data to WCF RESTful Service using jQuery

The POST request method is basically designed to post data to a web server for storage. That's why its normally used when submitting a complete form. In this WCF RESTful service tutorial, I'll try to explain how we can post JSON data to a WCF RESTful service using jQuery Ajax call with POST type. We discussed about "POST" HTTP verb in previous WCF tutorials but we didn't use it in our implementation. Purpose of this article is to understand "POST" request with complete implementation for a specific operation.

GridView Confirmation Box Using JQuery BlockUI in asp.net

JQuery is the most popular JavaScript library. One of the main reasons for its fame is the plugin architecture. Anyone can create a separate library that leverage the JQuery library. In this article we are going to look at the BlockUI library which is used to block the user screen while performing a task.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend