Click here to Skip to main content
15,894,955 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I take the coding reference http://www.aspsnippets.com/Articles/AJAX-Cascading-DropDownList-using-jQuery-in-ASP.Net.aspx.Net.aspx">http://www.aspsnippets.com/Articles/AJAX-Cascading-DropDownList-using-jQuery-in-ASP.Net.aspx[^]

The modify the code as below

XML
<script type = "text/javascript">
    var pageUrl = '<%=ResolveUrl("~/vendor_master.aspx")%>'
    function PopulateStates() {
        if ($('#<%=ddl_state.ClientID%>').val() == "0") {
            $('#<%=ddl_city.ClientID %>').empty().append('<option selected="selected" value="0">Please select</option>');
        }
        else {
            $('#<%=ddl_city.ClientID %>').empty().append('<option selected="selected" value="0">Please select</option>');
            $.ajax({
                type: "POST",
                url: 'vendor_master.aspx/PopulateCities',
                data: '{stateID: ' + $('#<%=ddl_state.ClientID%>').val() + '}',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnCitiesPopulated,
                failure: function (response) {
                    alert(response.d);
                }
            });
        }
    }
    function OnCitiesPopulated(response) {
        PopulateControl(response.d, $('#<%=ddl_city.ClientID %>'));
    }
</script>


But it gives me an error

VB
ReferenceError: PopulateControl is not defined


PopulateControl(response.d, $('#ddl_city'));


please help me to solve the error
Posted
Comments
jaket-cp 30-Jan-15 4:24am    
Did you read the "Populating the DropDownLists with data" part
and put in the PopulateControl function ?
Omkar Hendre 30-Jan-15 4:38am    
Thanks friend i got it n sorry for giving trouble you sorry dear

1 solution

That is because you have not defined that function. As per the link you have given, it is...
HTML
<script type = "text/javascript">
function PopulateControl(list, control) {
    if (list.length > 0) {
        control.removeAttr("disabled");
        control.empty().append('<option selected="selected" value="0">Please select</option>');
        $.each(list, function() {
            control.append($("<option></option>").val(this['Value']).html(this['Text']));
        });
    }
    else {
        control.empty().append('<option selected="selected" value="0">Not available<option>');
    }
}
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900