Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello there
I am very new to MVC
I have created a partial view as bellow
the controller

C#
public class Pv_AddressController : BaseController
    {
        //
        // GET: /Pv_Address/
        public ActionResult Index()
        {
            AddressModel model = new AddressModel();
            return View(model);
        }
        


        //
        // GET: /Pv_Address/Details/5
        public ActionResult GetAddress(string home, string postcode)
        {
          List< AddressModel> model = AddressUtility.FindAddressByPostcode(home, postcode,false);         
          return View(model);
        }

view for Index as bellow
HTML
@model Account_Portal.Models.AddressModel

@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>AddressModel</h4>
        <hr />
        <p>
            @Html.Label("House Number or Name")
            @Html.EditorFor(model => model.AddressLine1)
        </p>
       <p>
           @Html.LabelFor(model => model.Postcode)
           @Html.EditorFor(model => model.Postcode)
       </p>
   
    </div>
}

<div>
    @Html.ActionLink("Continue", "GetAddress", new { home = Model.AddressLine1, postcode =Model.Postcode }) 
    @Html.ActionLink("Don't Know the Postcode", "ManuallyEnter", new { type = "ManuallyAdd" })|
    @Html.ActionLink("BFPO Customer", "ManuallyEnter", new { type = "BFPO" })
</div>

now I wanted is to include the partial view the AddressChangeController

the controller i have got is
C#
public class AddressChangeController : Controller
    {
        //
        // GET: /ChangeBillingAddress/
        public ActionResult Index()
        {
            ChangeAddressModel model = new ChangeAddressModel();

            return View(model;
        }

and the view is
HTML
@model AccountPortal.Models.ChangeBillingAddressModel

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryval")
    
    
    @using (Html.BeginForm()) 
    {
        @Html.AntiForgeryToken()
        
        //want to include the pv_addressController 
    }
    
    <div>
        @Html.ActionLink("Back to List", "Index")
    </div>
</body>
</html>

how do i include the pv_addressController in my main view
appreciate all your help
Posted
Comments
AlexDpars 3-Dec-13 9:49am    
I don't understand what you want... You want to include you controller in your view? Or you partial view?
AlexDpars 3-Dec-13 9:52am    
By the way if you are new to MVC I would suggest you to read this http://www.codeproject.com/Articles/207797/Learn-MVC-Model-View-Controller-step-by-step-in-7
This is a good tutorial to intruduce new people to MVC

1 solution

First of all, when you call any action for partial view then you have return the as PartialView();

From your .aspx or .cshtml you have to call the Action after

C#
@Html.AntiForgeryToken();
@Html.Action("Index","AddressChangeController");
 
Share this answer
 

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