Click here to Skip to main content
15,902,492 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.................
Posted

1 solution

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.
 
Share this answer
 
v2
Comments
Member 10714619 25-Apr-14 0:51am    
ok sir, thanks for suggession.........
Snesh Prajapati 25-Apr-14 1:35am    
You are most welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900