I have jquery and I try to map with webmethod written in c#. but do not know what to do....with dictionary c#.
Please helps
<select id="PRODUCT_LIST" name="PRODUCT_LIST"> should show up
like
<option value="1">1000</option>
<option value="2">2000</option>
Thanks,
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Mas
ter" AutoEventWireup="true" CodeBehind="Tester5.aspx.c
s" Inherits="AppService.Teste
r5" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head
" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Cont
entPlaceHo
lder1" runat="server">
<select onchange="ShowList()" runat="server" required class="form-control" id="PRODUCT_CODE" name="PRODUCT_CODE">
<option value="" disabled="disabled" selected="selected" class="disabled">Product Code</option>
<option value="13081">13081</optio
n>
<option value="13082">13082</optio
n>
</select>
<br />
<select onchange="ShowList()" runat="server" required class="form-control" id="PRODUCT_STATE" name="PRODUCT_STATE">
<option value="" disabled="disabled" selected="selected" class="disabled">Product State</option>
<option value="ND">ND</option>
<option value="OH">OH</option>
<option value="ZZ">All Others</option>
</select>
<br />
<select style="display:none;" runat="server" required class="form-control" id="PRODUCT_LIST" name="PRODUCT_LIST"></sele
ct>
<script src="
http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></s
cript>
<script type = "text/javascript">
function ShowList() {
$.ajax({
type: "POST",
url: "Tester5.aspx/GetList",
data: '', //?
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
//?
}
</script>
</asp:Content>
//code behind:
[System.Web.Services.WebMe
thod]
public static Dictionary<string,string>G
etList(str
ing PRODUCT_CODE, string PRODUCT_STATE)
{
Dictionary<string,string> s = new Dictionary<string,string>(
);
s.Add("1", "1000");
s.Add("2", "2000");
return s;
}
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.