Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can i get the value selected in @Html.DropDownList in a MVC3
    primarykey
    data
    text
    <p>I have this code, how can I get the selected value of the @htmlDropDownList to put this value in my @Url.Action instead of <strong>1</strong>, 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</p> <pre><code>var idempresa = $('IdEmpresa').val() &lt;a href="@Url.Action("List","Script")?idempresa=**idempresa**" </code></pre> <p>the code:</p> <pre><code>@using (Html.BeginForm()) { @Html.ValidationSummary(true) &lt;fieldset&gt; &lt;legend&gt;Script&lt;/legend&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.IdEmpresa, "Empresa") &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.DropDownList("IdEmpresa", String.Empty ) @Html.ValidationMessageFor(model =&gt; model.IdEmpresa) &lt;/div&gt; &lt;/fieldset&gt; } href="@Url.Action("List","Script")?idempresa=**1**" </code></pre> <p>pd. thank you for the help</p> <p>Edit:</p> <pre><code> @using System.Web.Mvc.Html @model SistemaDispositivos.Models.Script @{ ViewBag.Title = "Script"; } &lt;h2&gt;Script&lt;/h2&gt; &lt;script src="../../Scripts/jquery-1.6.2.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt; @using (Html.BeginForm()) { @Html.ValidationSummary(true) &lt;fieldset&gt; &lt;legend&gt;Script&lt;/legend&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.IdEmpresa, "Empresa") &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.DropDownList("IdEmpresa", String.Empty) @Html.ValidationMessageFor(model =&gt; model.IdEmpresa) &lt;/div&gt; &lt;/fieldset&gt; } &lt;script type="text/javascript" language="javascript"&gt; $(document).ready(function () { var url1 = '@Url.Action("List","Script")?idempresa='; $('IdEmpresa').change(function() { $urlId = $('urlid'); $urlId.attr('href', url + $(this).val()); }); }); &lt;/script&gt; &lt;a id="urlid" href="@Url.Action("List","Script")?idempresa=url1"&gt; &lt;/a&gt; </code></pre> <p>What iam missing?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload