使用json 和jQuery制作级联dropdownlist

联动式的下拉选择是一个很普遍的需求,在ASP.NET MVC中可以使用Json和jQuery来实现,更简单的是使用jQuery的级联插件CascadingDropDown ,具体参见文章http://weblogs.asp.net/rajbk/archive/2010/05/20/cascadingdropdown-jquery-plugin-for-asp-net-mvc.aspx

1: $(targetID).CascadingDropDown(sourceID, actionPath, settings) 
   2:  
   3: •targetID 
   4: The ID of the select list that will auto populate.  
   5:  
   6: •sourceID 
   7: The ID of the select list, which, on change, causes the targetID to auto populate. 
   8:  
   9: •actionPath 
  10: The url to post to 
  11: Options
  12:  
  13: •promptText 
 14: Text for the first item in the select list 
  15: Default : -- Select -- 
  16:  
  17: •loadingText 
  18: Optional text to display in the select list while it is being loaded. 
  19: Default : Loading.. 
  20:  
  21: •errorText 
  22: Optional text to display if an error occurs while populating the list 
  23: Default: Error loading data. 
  24:  
  25: •postData 
  26: Data you want posted to the url in place of the default 
  27: Example : 
  28: postData: function () { 
  29:     return { prefix: $('#txtPrefix').val(), customerID: $('#customerID').val() }; 
  30: } 
  31: will cause prefix=foo&customerID=bar to be sent as the POST body. 
  32: Default: A text string obtained by calling serialize on the sourceID 
  33:  
  34: •onLoading (event) 
  35: Raised before the list is populated. 
  36:  
  37: •onLoaded (event) 
  38: Raised after the list is populated, The code below shows how to “animate” the  select list after load.

本文来自云栖社区合作伙伴“doNET跨平台”,了解相关信息可以关注“opendotnet”微信公众号

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值