I would like to force uppercase on a textbox in my view. So when user type something in the textbox, either the text is immediately converted in uppercase or (an alternative) the text is converted in uppercase when the form is submitted and the model is populated with data (in the action controller). Maybe there are some CSS or jquery solutions but I prefer some MVC solutions (if possible).
Here is my view:
@model Domain.Entities.ProjectTechnology
<script src="../../Scripts/Admin/_AddProjectTechnology.js" type="text/javascript"></script>
<div class="editor-label">Technologies</div>
<div class="editor-field">
@using (Ajax.BeginForm("_AddProjectTechnology", new AjaxOptions { HttpMethod = "POST",
UpdateTargetId = "RemoveProjectTechnology",
InsertionMode = InsertionMode.Replace,
OnComplete = "AddProjectTechnologyCompleted" })) {
@Html.ValidationSummary(true)
@Html.HiddenFor(m => m.ProjectID)
@Html.EditorFor(m => m.TechnologyID)
@Html.ValidationMessageFor(m => m.TechnologyID)
}
</div>
And here is my model:
public class ProjectTechnology
{
public int ProjectID { get; set; }
public string TechnologyID { get; set; }
}
The textbox in question is this line: @Html.EditorFor(m => m.TechnologyID)
How can I proceed ?
Thanks.
You could perform this conversion on the getter of the property: