如何将列表框控件的选定值传递给mvc中的文本框控件 [英] how to pass the selected value of a listbox contol to textbox control in mvc

查看:105
本文介绍了如何将列表框控件的选定值传递给mvc中的文本框控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将列表框控件的选定值传递给mvc中的文本框控件

解决方案

阅读: ASP.Net MVC - 如何创建ListBox? [ ^ ]



在Index方法中,您将从列表框中获取所选值。而是在这里,将您选择的值存储在ViewBag中,并在文本框的视图中加载该值。



另一种方法是,将选定的值绑定到模型并传递给它到了视野。并使用 @ Html.TextBoxFor()来渲染该值。





-KR

how to pass the selected value of a listbox contol to textbox control in mvc

解决方案

Read this: ASP.Net MVC – How to create a ListBox?[^]

Here on Index method, you'd be getting the selected value from the listbox. Instead here, store your selected value in ViewBag and load that value in the view for the textbox.

Another approach is, bind the selected value to the model and pass it to the view. And use @Html.TextBoxFor() to render the value.


-KR


这篇关于如何将列表框控件的选定值传递给mvc中的文本框控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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