All partial views in switch statement rendered, and not the selected value.
I have a small problem. I have some html select markup, when on change I need to render a partial view based on the select statement. I have a switch case in some javascript, but what happens when I load the page, both Html.Paritials are being rendered.
The partials are created in the backoffice.
my code looks like this:
//My attempt at the function for the rendering of partials
function SendMail() {
var select = document.getElementById("foo");
var selected = select.options[select.selectedIndex].value;
console.log("Test")
switch (selected) {
case '0':
break;
case '1':
alert(selected)
@*$.ajax({ url: @Url.Action("Web/Partial1", @Model.Boo)})*@
break;
case '2':
alert(selected)
@*$.ajax({ url: @Url.Action("Web/Partial2", @Model.Boo)})*@
break;
}
}
But both of the partials in the switch statement are being rendered, but the alert and test log is not compiled, but if the ajax calls are commented out, then they are compiled as expected.
ps. I need to add, that the 2 partial views is working as handlers, which when rendered sends an email, so there is no actual view to be shown. But what happens is that both mails are being send as soon as the page is loaded.
All partial views in switch statement rendered, and not the selected value.
I have a small problem. I have some html select markup, when on change I need to render a partial view based on the select statement. I have a switch case in some javascript, but what happens when I load the page, both Html.Paritials are being rendered. The partials are created in the backoffice.
my code looks like this:
And the html markup looks like this:
But both of the partials in the switch statement are being rendered, but the alert and test log is not compiled, but if the ajax calls are commented out, then they are compiled as expected.
ps. I need to add, that the 2 partial views is working as handlers, which when rendered sends an email, so there is no actual view to be shown. But what happens is that both mails are being send as soon as the page is loaded.
is working on a reply...