I'm trying to replicate the answer found below: is it posible do have Html.ActionLink inside a DropDownList Without java script?
@Html.DropDownList(
"url",
new SelectList(new[]
{
new SelectListItem { Text = "Home", Value = Url.Action("Home", "Home") },
new SelectListItem { Text = "About", Value = Url.Action("About", "Home") },
new SelectListItem { Text = "Contact", Value = Url.Action("Contact", "Home") },
}, "Value", "Text"),
"Change View",
new { id = "urlddl" }
)
$(function() {
$('#urlddl').change(function() {
var url = $(this).val();
if (url != null && url != '') {
window.location.href = url;
}
});
});
The problem is, when i select an item in the DropDownList, nothing happened. Any help is greatly appreciated.
Edit: I've edit it to what it was suppose to be. I edit the code and paste the wrong one.