I have this code, how can I get the selected value of the @htmlDropDownList to put this value in my @Url.Action instead of 1, I have read using javascript o jquery but i cant figure out how can i do that in the view directly, and this is not working for my
var idempresa = $('IdEmpresa').val()
<a href="@Url.Action("List","Script")?idempresa=**idempresa**"
the code:
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Script</legend>
<div class="editor-label">
@Html.LabelFor(model => model.IdEmpresa, "Empresa")
</div>
<div class="editor-field">
@Html.DropDownList("IdEmpresa", String.Empty )
@Html.ValidationMessageFor(model => model.IdEmpresa)
</div>
</fieldset>
}
href="@Url.Action("List","Script")?idempresa=**1**"
pd. thank you for the help
Edit:
@using System.Web.Mvc.Html
@model SistemaDispositivos.Models.Script
@{
ViewBag.Title = "Script";
}
<h2>Script</h2>
<script src="../../Scripts/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Script</legend>
<div class="editor-label">
@Html.LabelFor(model => model.IdEmpresa, "Empresa")
</div>
<div class="editor-field">
@Html.DropDownList("IdEmpresa", String.Empty)
@Html.ValidationMessageFor(model => model.IdEmpresa)
</div>
</fieldset>
}
<script type="text/javascript" language="javascript">
$(document).ready(function () {
var url1 = '@Url.Action("List","Script")?idempresa=';
$('IdEmpresa').change(function() {
$urlId = $('urlid');
$urlId.attr('href', url + $(this).val());
});
});
</script>
<a id="urlid" href="@Url.Action("List","Script")?idempresa=url1"> </a>
What iam missing?
well it work now this is what I wanted thank for the help:
so now in the div Lista-Script when I click the button I get my view that I wanted