2
I am making an application where the user chooses an option and a different form is shown for each of these options.
My problem is that when I change the option, I cannot change to the corresponding partial view.
In the Shared folder I created 4 Partial Views
- _partialView1
 - _partialView2
 - _partialView3
 - _partialView4
 
I just entered a tag with the number!
In HTML + Jquery:
I also tried to make an append("@Html.Partial("_partialView1")") but it didn’t work...
<script>
        $(document).ready(function () {
            $("#dropdown").change(function () {
                var str = "";
                $("select option:selected").each(function () {
                    str = $(this).text();
                    if (str == "OP 1") {
                        $("#MyPartialView").load("/_partialView1");
                    }
                    else if (str == "OP 2") {
                        $("#MyPartialView").load("/_partialView2");
                    }
                    else if (str == "OP 3") {
                        $("#MyPartialView").load("/_partialView3");
                    }
                    else {
                        $("#MyPartialView").load("/_partialView4");
                    }
                });
            });
        });
</script>
<select id="dropdown" class="form-control col-sm-2 mb-5 mt-5" name="opcao">
    <option>OP 1</option>
    <option>OP 2</option>
    <option>OP 3</option>
    <option>OP 4</option>
</select>
<div id="MyPartialView">
    @Html.Partial("_partialView1")
</div>
This is not how a partial view works, there is no way to load a partial view ( C# ) with Jquery. I suggest you bring all partial views and then control their visibility through Jquery will be more productive and simple to be done.
– William