Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Html.RenderAction in MVC

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 43
    Comment on it

    While working in MVC you need to sometime work upon the partial view.

     

     

    Partial view is nothing but like a user control that is used to placed on the pages where something needs to be done again and again.

     

     

    So creating partial view is like creating first the action in the controller.

     

     

     public ActionResult _DetailPartial()
            {
                Partial_View.Models.EmployeeModel obj = new Models.EmployeeModel();
                obj.Address = "Dehradun";
                obj.PhoneNo = "7579414837";
                return PartialView(obj);
            }

     

     

    After this you need to render your partial view into the view where you want to use it.

     

     

    @model Partial_View.Models.EmployeeModel
    
    <div>
        <h4>EmployeeModel</h4>
        <hr />
        <dl class="dl-horizontal">
            <dt>
                @Html.DisplayNameFor(model => model.EmpId)
            </dt>
    
            <dd>
                @Html.DisplayFor(model => model.EmpId)
            </dd>
    
            <dt>
                @Html.DisplayNameFor(model => model.FirstName)
            </dt>
    
            <dd>
                @Html.DisplayFor(model => model.FirstName)
            </dd>
    
            <dt>
                @Html.DisplayNameFor(model => model.MiddleName)
            </dt>
    
            <dd>
                @Html.DisplayFor(model => model.MiddleName)
            </dd>
    
            <dt>
                @Html.DisplayNameFor(model => model.LastName)
            </dt>
    
            <dd>
                @Html.DisplayFor(model => model.LastName)
            </dd>
        </dl>
    </div>
    
    
    
    @{Html.RenderAction("_DetailPartial", "Home");}
    
    
    
    
    
    

     

    The last line will load the partial view into the present view when the page is displayed.

    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: