开发者

Fill textboxes based upon current Dropdownlist (database items) selection (asp.NET MVC)

I have a dropdown box in my view which is populated with objects from database. Now what I want to do is, based upon selection in the Dropdown fill various textboxes with property values of the object selected in the dropdownlist.

There are numerous examples where you copy the selected dropdown value in the textbox using JQuery / JavaScript etc, but I can't find any doing the same but instead of copying; place the values of the properties of the object in the textboxes.

How would this be done in a nice way? I would prefer to do it without posting the entire form, though those 开发者_如何学Canswers may be posted also.


 $('select#yourControlId').change(function () {
    var selectedVal = $(this).val();

    document.location = '<%= Url.Action( "Action", "Controller") %>' + '?val=' + selectedVal;
 });

Then you'll capture val in the signature of teh action method and populate the appropriate textboxes...

Or

You could also on Changed do a JQuery Ajax post...

http://api.jquery.com/jQuery.ajax/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜