Advertisement
taylorp0994

ServerSideValidator.ascx.cs

Sep 17th, 2018
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2. using CMS.FormEngine.Web.UI;
  3. using CMS.Helpers;
  4. // ReSharper disable ArrangeAccessorOwnerBody
  5.  
  6. namespace CMSApp.CMSFormControls.Custom
  7. {
  8.     public partial class ServerSideValidator : FormEngineUserControl
  9.     {
  10.         public override object Value
  11.         {
  12.             get { return txtValue.Value; }
  13.             set { txtValue.Value = ValidationHelper.GetString(value, string.Empty); }
  14.         }
  15.  
  16.         protected override void OnInit(EventArgs e)
  17.         {
  18.             Form.SubmitButton.Click += SubmitButtonOnClick;
  19.             base.OnInit(e);
  20.         }
  21.  
  22.         private void SubmitButtonOnClick(object sender, EventArgs e)
  23.         {
  24.             var valid = CustomValidationHelper.ServerSideValidationMethod(Value);
  25.  
  26.             if (!valid)
  27.             {
  28.                 //TODO: Invalidate the form before save or notify. (Form.?)
  29.             }
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement