I am working mvc dropdownlist helpers.I am new to MVC
here is my issue,
I have 2 dropdowns on the page.One is for country ,other is for states for the country which has been selected.
I am using Jquery to postback to server and buliding the list and giving to browser.
Every thing works fine on the server side but when I try to see the data on the Browser side.It is giving System.Collections.generic.... in 'data' variable at client side.
beingcoder20...
Member
36 Points
27 Posts
Unable to get data list from server code.
Sep 23, 2011 01:51 AM|LINK
Hi,
I am working mvc dropdownlist helpers.I am new to MVC
here is my issue,
I have 2 dropdowns on the page.One is for country ,other is for states for the country which has been selected.
I am using Jquery to postback to server and buliding the list and giving to browser.
Every thing works fine on the server side but when I try to see the data on the Browser side.It is giving System.Collections.generic.... in 'data' variable at client side.
here is my code,
.aspx:
asteranup
All-Star
30184 Points
4906 Posts
Re: Unable to get data list from server code.
Sep 23, 2011 07:46 AM|LINK
Hi,
There are few posts for calling controller method from jquery-
http://forums.asp.net/p/1655438/4311291.aspx/1?Re+Correct+way+to+fire+controller+method+with+Jquery
http://forums.asp.net/p/1650403/4292279.aspx#4292279
http://forums.asp.net/t/1627118.aspx
http://forums.asp.net/p/1658781/4324955.aspx
For creating dropdownlist using jquery and for cascading dropdown you can check
http://www.delicious.com/anupdg/dropdown+cascading
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
beingcoder20...
Member
36 Points
27 Posts
Re: Unable to get data list from server code.
Sep 23, 2011 04:20 PM|LINK
Hai Thanks for your reply..
From the links you suggested I worked on this link..
http://forums.asp.net/t/1655438.aspx/3/10?Re+Correct+way+to+fire+controller+method+with+Jquery
I wrote my code ,please find my code,
and every thing works fine..But the only problem I am having is with this statement.
$('#State').append('<option value="' + value.Value + '">' + value.Text + '</option>');
Every time I am calling the server,the results are appending to the previous results,
Like this,
If I select Canada ,its giving AndhraPrades,TamilNadu in the second dropdown.
If I select UnitedStates,its givng AndhraPrades,TamilNadu,Florida,California in the second dropdown.
I hope you understand my problem.
It will be great if you help on this issue.
Regards..
beingcoder20...
Member
36 Points
27 Posts
Re: Unable to get data list from server code.
Sep 23, 2011 04:45 PM|LINK
I got it using
$('#State').children().remove();
Thanks every one..