none
How To display partial View Under another partial View RRS feed

  • Question

  • Hi Actually i Have To partial View one is _chapterforcourse and another one is _subjectchapter 

    i need to display when i click Subject name button i need to open onother partial view please help me any one 

    Controller Code

    public PartialViewResult chapterupload(string keyword)
            {
                using (EOTAEntities db = new EOTAEntities())
                {
                    var products = (from pcrs in db.Courses

                                    where pcrs.Course_name.ToUpper() == keyword.ToUpper()

                                    select pcrs).Distinct().FirstOrDefault();
                    ViewBag.subject = (from pcrs in db.Courses

                                          where pcrs.Secret_Code == products.Secret_Code

                                          select pcrs).Distinct().ToList();

                    return PartialView("_chapterforCourse", products);
                }
            }
            public PartialViewResult chapterdetails(string keyword)
            {
                using (EOTAEntities db = new EOTAEntities())
                {
                    var products = (from pcrs in db.Courses

                                    where pcrs.Subject_Name.ToUpper() == keyword.ToUpper()

                                    select pcrs).Distinct().FirstOrDefault();
                    var subject = (from pcrs in db.Courses

                                       where pcrs.Subject_Code == products.Subject_Code

                                       select pcrs).Distinct().FirstOrDefault();
                    ViewBag.subj = subject.Subject_Name;

                    return PartialView("_subjectchapter", products);
                }
            }

    Partial View Code

    _ChapterforCourse

    @model EtreetrainingUser.Models.Cours
    @{
                    /**/

                    /**/

                    Layout = null;
    }
    @using (Html.BeginForm("chapterdetails", "Home", FormMethod.Post, new { enctype = "multipart/form-data", role = "form" }))
    {

        @*@Html.AntiForgeryToken()*@



        <button type="button" class="close" onclick="closechp1function1()" aria-label="Close" style="padding:5px 5px 5px 5px">
            <span aria-hidden="true">&times;</span>
        </button>

        <div style="padding:15px 15px 15px 15px">
            @{int count = 1; var scrt = 0; }
            @{
                foreach (var crs in ViewBag.subject)
                {
                    using (Ajax.BeginForm("chapterdetails", "Home", new AjaxOptions
                    {
                        HttpMethod = "GET", // HttpMethod to use, GET or POST
                        UpdateTargetId = "pyc2", // ID of the HTML element to update
                        InsertionMode = InsertionMode.Replace
                    }))

                    {
                        if (count == 1)
                        {

                        }
                        else if (count == 2)
                        {
                            @Html.HiddenFor(model => model.Subject_Code)
                            <input type="submit" style="cursor:pointer;font-weight: 600;font-size: 15px;line-height: 1.43;color: white;background-color:#02b3e4;width:75px;" name="keyword" value="@crs.Subject_Name" />

                        }
                        else if (count == 3)
                        {
                            @Html.HiddenFor(model => model.Subject_Code)
                            <input type="submit" style="cursor:pointer;font-weight: 600;font-size: 15px;line-height: 1.43;color: white;background-color:#02b3e4;width:75px;" name="keyword" value="@crs.Subject_Name" />

                        }
                        else if (count == 4)
                        {
                            @Html.HiddenFor(model => model.Subject_Code)
                            <input type="submit" style="cursor:pointer;font-weight: 600;font-size: 15px;line-height: 1.43;color: white;background-color:#02b3e4;width:75px;" name="keyword" value="@crs.Subject_Name" />

                        }
                        else if (count == 5)
                        {
                            @Html.HiddenFor(model => model.Subject_Code)
                            <input type="submit" style="cursor:pointer;font-weight: 600;font-size: 15px;line-height: 1.43;color: white;background-color:#02b3e4;width:75px;" name="keyword" value="@crs.Subject_Name" />

                        }
                        else if (count == 6)
                        {
                            @Html.HiddenFor(model => model.Subject_Code)
                            <input type="submit" style="cursor:pointer;font-weight: 600;font-size: 15px;line-height: 1.43;color: white;background-color:#02b3e4;width:75px;" name="keyword" value="@crs.Subject_Name" />

                        }

                        count++;
                    }
                }

            }

        </div>   
    }

    <script>

        $(document).ready(function () {
            document.getElementById('pyc3').style.display = 'none'; document.getElementById('pyc4').style.display = 'none'; document.getElementById('sub1').style.display = 'none'; document.getElementById('chp28').style.display = 'block';
        })
    </script>

     2) _subjectchapter

    @model EtreetrainingUser.Models.Cours
    @{
                    /**/

                    Layout = null;
    }
        @using (Html.BeginForm("Doc_upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data", role = "form" }))
        {

            @*@Html.AntiForgeryToken()*@


    <label style="text-align:center;color:white;padding:10px 0px 0px 0px">Details for @ViewBag.subj </label>
            <button type="button" class="close" onclick="closefunction1()" aria-label="Close" style="padding:5px 5px 5px 5px">
                <span aria-hidden="true">&times;</span>
            </button>
                   <div style="padding:15px 15px 15px 15px" id="mainrowforvideos" class="col-lg-12 col-md-12 col-sm-12">
                    <div class="col-lg-12 col-md-12 col-sm-12">
                        @Html.EditorFor(model => model.Subject_Name, new { htmlAttributes = new { @class = "sub", @style = "float:left;padding:10px 100px 10px 10px", @value = @ViewBag.subj, @disabled = "disabled" } })
                        @Html.HiddenFor(model => model.Secret_Code)
                        @Html.HiddenFor(model => model.Subject_Code)
                        @Html.EditorFor(model => model.Chapter_number, new { htmlAttributes = new { @class = "chno", @style = "float:left; width:70px;padding:10px 10px 10px 5px", @placeholder = "No." } })

                        @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "ttl", @style = "float:left;padding:10px 10px 10px 10px", @placeholder = "Title" } })

                        @Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "des", @style = "float:left;padding:10px 100px 10px 10px", @placeholder = "Description" } })



                    </div>
                   </div>
            }
            <input class="btn btn-success" type="submit" style="background-color:yellow; margin-top:20px ; float:right;padding:5px 5px 5px 5px; color:black; width:10%;" value="Update">
        }

    <script>

        $(document).ready(function () {
            document.getElementById('pyc3').style.display = 'none'; document.getElementById('pyc4').style.display = 'none'; document.getElementById('ryv1').style.display = 'none'; document.getElementById('pyc2').style.display = 'block';
        })
    </script>

    1st Partial is working Fine but when i click subject name button second partial view open like Razor view(main View) but i need partial view.... 

    I tried do that but i can't i'm stragle to do please any one help 

    Thanks In Advance 

    Darshan Kumar B


    Darshan Kumar B

    • Moved by CoolDadTx Thursday, May 30, 2019 1:38 PM ASP.NET related
    Thursday, May 30, 2019 10:00 AM

All replies

  • Hello,

    I would recommend posting your question in the ASP.NET forum.

    https://forums.asp.net/


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Thursday, May 30, 2019 10:45 AM
  • Thanks For Your Siggistion....

    I'll Do that


    Darshan Kumar B

    Thursday, May 30, 2019 10:49 AM