Click here to Skip to main content
15,911,132 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there
I am very new to mvc

i got the below method in my controller class

C#
public class Pv_AddressController : BaseController
    {
      
      public ActionResult GetAddress(string home, string postcode)
        {
          List< AddressModel> model = AddressUtility.FindAddressByPostcode(home, postcode,false);         
          return View(model);
        }

public ActionResult AddressSelected (AddressModel addressSelected)
        {
            //convert address to Address object 
            return View();
        }
        
     }

what i am after is to create a view for GetAdress
where it got a drop down list to display all the address.Tostring() (I have override the Tostring()Method to return a string format of the address)
and a @Html.ActionLink to AddressSelected Methord with the selected address to be passed as the parameter
what i have got so for is
HTML
@model List<Account_Portal.Models.AddressModel>

<div>
    <h4>AddressModel</h4>
	<hr />
    <dl class="dl-horizontal">
        <fieldset>
            <select id="AddressList" name="AddressList">
                <option value="0" selected="selected">Please Select Your Address</option>
                @foreach (Account_Portal.Models.AddressModel add in Model)
          {
              <option value=add>add.Tostring()</option>
          }
            </select>
        </fieldset>



</div>
<p>
    @Html.ActionLink("Continue", "AddressSelected ", new { addressSelected = AddressList.Selected }) |
    @Html.ActionLink("Back to List", "Index")
</p>
Posted
Comments
AlexDpars 3-Dec-13 9:11am    
You will have to use JQUERY to acheive that http://stackoverflow.com/questions/20099684/mvc4-get-selected-text-of-dropdown-list-located-in-partial-view-every-time-i

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