[英]Call user defined function from JavaScript
我在網頁上有兩個下拉列表(州名稱和城市名稱)。 我要綁定城市名稱取決於所選的州名稱。 我寫了BindCities()函數來綁定CityNames下拉列表。 通過使用Dictionary,我將綁定這兩個下拉列表。
private void BindCity() {
try {
string Action = "BindCity";
int CompanyId = 1;
int StateId = Convert.ToInt32(ddlPresentState.SelectedValue);
Dictionary<int, string> dct = AppBll.BindCityNames(Action, CompanyId, StateId);
ddlPresentCity.DataSource = dct;
ddlPresentCity.DataValueField = "Key";
ddlPresentCity.DataTextField = "Value";
ddlPresentCity.DataBind();
}
catch (Exception) {
throw;
}
}
現在,我想從StateNames下拉列表的JavaScript OnChange事件中調用BindCities()函數。 但這是行不通的。 所以請幫我解決這個問題。 提前致謝。
ASPX
<asp:DropDownList runtat="server" Id="StateNames"
OnChange="StateNames_OnSelectedIndexChanged"></asp:DropDownList >
CS
public void StateNames_OnSelectedIndexChanged(object sender, EventArgs args)
{
BindCities();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.