MaskAttribute
- public void OnMetadataCreated(ModelMetadata metadata)
- {
- metadata.TemplateHint = "_maskInput";
- metadata.AdditionalValues["id"] = Guid.NewGuid();
- metadata.AdditionalValues["mask"] = Mask;
- }
Views\Shared\EditorTemplates\_maskInput.cshtml
- @using MvcLists.Common.CustomAttributes
- @model System.String
- @{
- var additionalValues = ViewData.ModelMetadata.AdditionalValues;
- var mask = additionalValues.SingleOrDefault(x=>x.Key=="mask").Value;
- var id = additionalValues.SingleOrDefault(x => x.Key == "id").Value;
- }
- @{ var maskedInput = ViewData.GetModelAttribute<MaskAttribute>();
- if (maskedInput != null)
- {
- <div class="editor-label">
- @Html.LabelForModel()
- </div>
- <div class="editor-field">
- @Html.TextBoxFor(m => m, new { id = @id })
- </div>
- }
- }
- <script type="text/javascript">
- $(document).ready(function () {
- $("#@id").mask('@mask');
- });
- </script>
1 comment:
Can you upload build solution for me?
Post a Comment