在asp.net MVC中点击按钮,从列表框中获取数据到文本框中 [英] Get data from listbox into textbox on button click in asp.net MVC

查看:435
本文介绍了在asp.net MVC中点击按钮,从列表框中获取数据到文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在asp.net MVC中点击按钮将列表框中的数据导入文本框。



任何人都可以告诉我如何做到这一点.. ...............

解决方案

示例代码如下:

 @using(Html.BeginForm(Index,Home))
{
@ Html.ListBoxFor(m => m.SelectedCountry,new SelectList(Model.CountryList,Value) ,Text,Model.CountryList.SelectedValue),new {@Id =lstcountry,@ style =width:200px; height:60px;})
< br /> < input type =submitvalue =Submittitle =submit/>
< input style =color:black;value =@ ViewBag.Country>< / input>
}



欲了解更多信息,请访问:



http://mvc-model.blogspot.in/2013/07/how-to -bind-listbox-in-mvc3-razor-with.html [ ^ ]



如果你想选择一个值从列表框同时,文本框的值应该改变,在这种情况下,你也可以使用javascript / jQuery。



希望它能帮到你...如果发布任何问题。


I wanted to know how to Get data from listbox into textbox on button click in asp.net MVC.

can anyone tell me how to do this.................

解决方案

Sample code is given below:

@using (Html.BeginForm("Index", "Home"))
{
    @Html.ListBoxFor(m => m.SelectedCountry, new SelectList(Model.CountryList, "Value", "Text", Model.CountryList.SelectedValue), new { @Id = "lstcountry", @style = "width:200px;height:60px;" })
    <br /> <input type="submit" value="Submit" title="submit" />
    <input style="color: black; " value="@ViewBag.Country"></input>
}


For more information visit:

http://mvc-model.blogspot.in/2013/07/how-to-bind-listbox-in-mvc3-razor-with.html[^]

If you want as you select a value from listbox simultaneously value of textbox should change in this case you can use javascript/jQuery also.

Hope it will help you...if any problem post it.


这篇关于在asp.net MVC中点击按钮,从列表框中获取数据到文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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