Skip to content
Loading
  
  •           
  •       
  •     @using (Ajax.BeginForm("CreateEdit", "Product", new AjaxOptions() { HttpMethod = "POST", UpdateTargetId = "frmProduct" }))  
  •     {  
  •         class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">  
  •             class="modal-dialog">  
  •                 class="modal-content">  
  •                     class="modal-header">  
  •                         "button" class="close" data-dismiss="modal">"true">×class="sr-only">Close  
  •                         class="modal-title">Add New Product  
  •                       
  •                     class="modal-body" id="frmProduct">  
  •                         @Html.Partial("_CreateEdit",Model.Location) //Note here  
  •                       
  •                     class="modal-footer">  
  •                         "button" class="btn btn-secondary" data-dismiss="modal">Cancel  
  •                         "submit" class="btn btn-primary">Save Changes  
  •                       
  •                   
  •               
  •           
  •     }  
  •   
  •   
  • Note:- Also in the partial view, you don't need Layout reference so remove @{Layout.... line.} 
    +1
  • +1
    Hi
     
       When clicked on Add it appears as below . Is it not possible that Partical View open only in content Page
     
     
    Below is the Partial View 

    @model MyApplication.Models.Location

    @{

    Layout = "~/Views/Shared/_Layout.cshtml";

    }

    <!DOCTYPE html>

    <html>

    <head>

    <meta name="viewport" content="width=device-width" />

    <title>CreateEdittitle>

    head>

    <body>

    @using (Html.BeginForm("CreateEdit", "Location", FormMethod.Post, new { @id = "locationFormId", @class = "form-horizontal", role = "form" }))

    {

    @Html.AntiForgeryToken()

    <div class="" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">

    <div class="modal-content">

    <div class="modal-header">

    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×span>button>

    <h4 Create New Location>h4>

    div>

    <div class="modal-body">

    @*

    Location


    *@

    @Html.ValidationSummary(true, "", new { @class = "text-danger" })

    @Html.HiddenFor(model => model.Id)

    <div class="form-group">

    @Html.LabelFor(model => model.Id, htmlAttributes: new { @class = "control-label col-md-2" })

    <div class="col-md-10">

    @Html.EditorFor(model => model.Id, new { htmlAttributes = new { @class = "form-control" } })

    @Html.ValidationMessageFor(model => model.Id, "", new { @class = "text-danger" })

    div>

    div>

    <div class="form-group">

    @Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" })

    <div class="col-md-10">

    @Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "form-control" } })

    @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })

    div>

    div>


    div>



    div>

    div>

    div>

    }


    body>

    html>

     
     
    Thanks 
    +1