How to set value of input text using jQuery

I have an input text which is this: <div class=”editor-label”> @Html.LabelFor(model => model.EmployeeId, “Employee Number”) </div> <div class=”editor-field textBoxEmployeeNumber”> @Html.EditorFor(model => model.EmployeeId) @Html.ValidationMessageFor(model => model.EmployeeId) </div> Which produce following html <div class=”editor-label”> <label for=”EmployeeId”>Employee Number</label> </div> <div class=”editor-field textBoxEmployeeNumber”> <input class=”text-box single-line” data-val=”true” data-val-number=”The field EmployeeId must be a number.” data-val-required=”The EmployeeId field is required.” … Read more

Why is JsonRequestBehavior needed?

Why is Json Request Behavior needed? If I want to restrict the HttpGet requests to my action I can decorate the action with the [HttpPost] attribute Example: [HttpPost] public JsonResult Foo() { return Json(“Secrets”); } // Instead of: public JsonResult Foo() { return Json(“Secrets”, JsonRequestBehavior.AllowGet); } Why isn’t [HttpPost]sufficient? Why the framework “bugs” us with … Read more

How to use ternary operator in razor (specifically on HTML attributes)?

With the WebForms view engine, I’ll commonly use the ternary operator for very simple conditionals, especially within HTML attributes. For example: <a class=”<%=User.Identity.IsAuthenticated ? “auth” : “anon” %>”>My link here</a> The above code will give the <a> tag a class of auth or anon depending on whether the user is authenticated. What is the equivalent … Read more