使用asp.net Web方法和jQuery动态填充下拉列表 [英] Dynamically populate dropdownlist using asp.net web methods and jQuery

查看:54
本文介绍了使用asp.net Web方法和jQuery动态填充下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有3个不同的下拉列表(< 选择 > 标签),现在我不想使用asp.net postbacks / codebehind来填充它们。列表中预先填充了世界各国的名称。现在我想使用asp.net web方法(返回json)和jQuery来填充STATES列表,该列表基于所选的国家(在list.change jQuery事件上)以及CITY列表等。请求帮助。

谢谢

解决方案

你需要选择你需要调用webservice的下拉和onchange事件并在下一个下拉列表中得到结果。就是这样.....例如





('。ddlCountry')。bind('更改',function(){

var CountryId =


('。ddlCountry')。val();

FillStates( CountryId);

}



FillStates = function(CountryId)

{

Hello,

I have 3 different dropdownlists (<select> tag) in my webform, now i don't want to use asp.net postbacks/codebehind to populate them.The first list pre-populated with the names of countries in the world. Now I want to use asp.net web methods (returns json) and jQuery to populate the STATES list based on the country selected (on list.change jQuery event) and so on for the CITY list. Pleas help.

Thanks

解决方案

You need to select the dropdown and onchange event u'll need to call a webservice and pu tthe result on the next dropdown. That's it.....for example



('.ddlCountry').bind('change', function () {
var CountryId =


('.ddlCountry').val();
FillStates(CountryId);
}

FillStates = function(CountryId)
{


这篇关于使用asp.net Web方法和jQuery动态填充下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆