Hi there,
i have some controls on my view like so: " ><%=Html.TextBox("Name")%> " ><%=Html.DropDownList("Intensities")%>
How can i retreive the values of these controls with JQuery?
Something like: var name = $("#name" + id).val(); alert(name);
Hi there,
i have some controls on my view like so: " ><%=Html.TextBox("Name")%> " ><%=Html.DropDownList("Intensities")%>
How can i retreive the values of these controls with JQuery?
Something like: var name = $("#name" + id).val(); alert(name);
well since <%=Html.TextBox("Name")%> make an input type="text" id="Name" name="Name" /> you could just
var name = $("#Name").val(); alert(name); var intensities = $("#Intensities").val(); alert(intensities );
In order to reference the textbox the way you propose you will need to give the textbox a custom id like this, supposing you're iterating over a collection of users:
<%foreach(var user in Model.UserCollection){%>
<%= Html.TextBox("Name",user.Name,new{id="name"+user.Id})%>
<%}%>