I'm new to ASP.Net development, MVC 5, and pretty much anything Windows, so I'm sure I'm doing something wrong. I searched around for an answer here and found similar questions but I'm clearly doing something wrong...probably due the answers presuming more knowledge of the environment I'm working in...
What happens is the selected box starts off as "Yes" which I would prefer to be "No", and the fields are displayed no matter.
I suspect I have the javascript in the wrong location and/or am missing something important.
I have a bit of code:
<p>
Are you a Licensee?
@Html.DropDownListFor(x => x.Licensee, new[] {
new SelectListItem() {Text="Yes", Value = bool.TrueString},
new SelectListItem() {Text="No", Value = bool.TrueString} }, new {id = "Licensee"})
@section scripts{ <script type="text/javascript">
$(function ()
{
$('#Licensee').change(function ()
{
var value = $(this).val();
if (value == true)
{
$('#LicName').show();
$('#LicUrl').show();
$('#LicRole').show();
}
else
{
$('#LicName').hide();
$('#LicUrl').hide();
$('#LicRole').hide();
}
});
});
</script> }
<p>Your Licensee Name: @Html.TextBoxFor(x => x.LicenseeName, new { id = "LicName" })</p>
<p>Your Licensee Url: @Html.TextBoxFor(x => x.LicenseURL, new { id = "LicUrl" })</p>
<p>your LIcensee Role: @Html.TextBoxFor(x => x.LicenseRole, new { id = "LicRole" })</p>
</p>