• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# WebControls.RequiredFieldValidator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Web.UI.WebControls.RequiredFieldValidator的典型用法代码示例。如果您正苦于以下问题:C# RequiredFieldValidator类的具体用法?C# RequiredFieldValidator怎么用?C# RequiredFieldValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RequiredFieldValidator类属于System.Web.UI.WebControls命名空间,在下文中一共展示了RequiredFieldValidator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: DynamicTextBox

        public DynamicTextBox(DynamicTextBoxXml xml)
        {
            _textBox = new TextBox();
            _textBox.CausesValidation = false;

            _required = new RequiredFieldValidator();
            _required.Display = ValidatorDisplay.Dynamic;
            _required.EnableClientScript = true;
            _required.Text = "*";
            _required.Enabled = false;
            _required.ClientIDMode = System.Web.UI.ClientIDMode.Static;

            this.Controls.Add(_textBox);
            this.Controls.Add(_required);

            this.ID = xml.Name;
            this.IsRequired = xml.IsRequired;
            this.ErrorMessage = xml.ErrorMessage;
            this.ValidationGroup = xml.ValidationGroup;
            this.MaxLength = xml.MaxLength;
            _textBox.Text = xml.Text;

            this.controlXML = xml;

            this.Visible = xml.Visible;
        }
开发者ID:danilocecilia,项目名称:HulcherProject,代码行数:26,代码来源:DynamicTextBox.cs


示例2: InitializeDataCell

 protected override void InitializeDataCell(DataControlFieldCell cell, DataControlRowState rowState)
 {
     //base.InitializeDataCell(cell, rowState);
     TextBox textBox = new TextBox();
     textBox.ID = this.ControlID;
     textBox.Width = new Unit(GridColumn.Width, UnitType.Pixel);
     if (GridColumn.Size != 0) textBox.MaxLength = GridColumn.Size;
     textBox.DataBinding += new EventHandler(this.textBox_DataBinding);
     base.InitializeDataCell(cell, rowState);
     cell.Controls.Add(textBox);
     CompareValidator vld = new CompareValidator();
     vld.ControlToValidate = textBox.ID;
     vld.ID = textBox.ID + "vld";
     vld.Operator = ValidationCompareOperator.DataTypeCheck;
     vld.ErrorMessage = "не верный формат (2)";
     vld.Text = "! (2)";
     vld.Display = ValidatorDisplay.Dynamic;
     if (GridColumn.Type == typeof(int)) vld.Type = ValidationDataType.Integer;
     if (GridColumn.Type == typeof(decimal)) vld.Type = ValidationDataType.Double;
     if (GridColumn.Type == typeof(string)) vld.Type = ValidationDataType.String;
     cell.Controls.Add(vld);
     if (!GridColumn.AllowNULL)
     {
         RequiredFieldValidator reqvld = new RequiredFieldValidator();
         reqvld.ControlToValidate = textBox.ID;
         reqvld.ID = textBox.ID + "reqvld";
         reqvld.ErrorMessage = "поле не может быть пустым (1)";
         reqvld.Text = "! (1)";
         reqvld.Display = ValidatorDisplay.Dynamic;
         cell.Controls.Add(reqvld);
     }
 }
开发者ID:vahtel65,项目名称:Aspect_loc,代码行数:32,代码来源:TextBoxProductGridField.cs


示例3: DynamicCountableTextBox

        public DynamicCountableTextBox(DynamicCountableTextBoxXml xml)
        {
            _textBox = new CountableTextBox();
            _textBox.CausesValidation = false;

            _required = new RequiredFieldValidator();
            _required.Display = ValidatorDisplay.Dynamic;
            _required.EnableClientScript = true;
            _required.Text = "*";
            _required.Enabled = false;
            _required.ClientIDMode = System.Web.UI.ClientIDMode.Static;

            this.Controls.Add(_textBox);
            this.Controls.Add(_required);

            this.ID = xml.Name;
            this.IsRequired = xml.IsRequired;
            this.ErrorMessage = xml.ErrorMessage;
            this.ValidationGroup = xml.ValidationGroup;

            this.MaxChars = xml.MaxChars;
            this.MaxCharsWarning = xml.MaxCharsWarning;
            this.TextMode = xml.TextMode;
            this.Width = new Unit(xml.Width);
            this.Height = new Unit(xml.Height);
            _textBox.Text = xml.Text;

            this.Visible = xml.Visible;

            this.controlXML = xml;

            this.Style[HtmlTextWriterStyle.Display] = "block";
        }
开发者ID:danilocecilia,项目名称:HulcherProject,代码行数:33,代码来源:DynamicCountableTextBox.cs


示例4: CreateChildControls

        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Label lblQuestion = new Label();
            _ddAnswer = new DropDownList();
            RequiredFieldValidator valQuestion = new RequiredFieldValidator();

            lblQuestion.ID = "lbl" + _question.QuestionGuid.ToString().Replace("-", String.Empty);
            _ddAnswer.ID = "dd" + _question.QuestionGuid.ToString().Replace("-", String.Empty);
            valQuestion.ID = "val" + _question.QuestionGuid.ToString().Replace("-", String.Empty);

            lblQuestion.Text = _question.QuestionText;
            lblQuestion.AssociatedControlID = _ddAnswer.ID;

            valQuestion.ControlToValidate = _ddAnswer.ID;
            valQuestion.Enabled = _question.AnswerIsRequired;

            _ddAnswer.Items.Add(new ListItem(Resources.SurveyResources.DropDownPleaseSelectText, String.Empty));

            foreach (QuestionOption option in _options)
            {
                ListItem li = new ListItem(option.Answer);
                if (li.Value == _answer) li.Selected = true;
                _ddAnswer.Items.Add(li);
            }

            valQuestion.Text = _question.ValidationMessage;

            Controls.Add(lblQuestion);
            Controls.Add(_ddAnswer);
            Controls.Add(valQuestion);
        }
开发者ID:joedavis01,项目名称:mojoportal,代码行数:32,代码来源:DropDownListQuestion.cs


示例5: DynamicDropDownList

        public DynamicDropDownList(DynamicDropDownListXml xml)
        {
            _dropdown = new DropDownList();
            _dropdown.CausesValidation = false;

            _required = new RequiredFieldValidator();
            _required.Display = ValidatorDisplay.Dynamic;
            _required.EnableClientScript = true;
            _required.Text = "*";
            _required.Enabled = false;
            _required.ClientIDMode = System.Web.UI.ClientIDMode.Static;

            this.Controls.Add(_dropdown);
            this.Controls.Add(_required);

            this.ID = xml.Name;
            this.IsRequired = xml.IsRequired;
            this.ErrorMessage = xml.ErrorMessage;
            this.ValidationGroup = xml.ValidationGroup;
            this.FilterId = xml.FilterId;
            if (!string.IsNullOrEmpty(xml.SelectedValue))
            {
                _dropdown.SelectedValue = xml.SelectedValue;
                _selectedValueOnLoad = xml.SelectedValue;
            }

            this.controlXML = xml;

            this.Visible = xml.Visible;
        }
开发者ID:danilocecilia,项目名称:HulcherProject,代码行数:30,代码来源:DynamicDropDownList.cs


示例6: CreateChildControls

        //Override the Create Child Controls event
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            //label for radio button list
            lblTFQuestion = new Label();
            lblTFQuestion.ID = "lblTFQuestion";
            lblTFQuestion.AssociatedControlID = "uxTFQuestion";
            lblTFQuestion.Text = QuestionText;

            //create radio button list
            uxTFQuestion = new RadioButtonList();
            uxTFQuestion.ID = "uxTFQuestion";

            //create validation for radio button list
            reqTFQuestion = new RequiredFieldValidator();
            reqTFQuestion.ID = "reqTFQuestion";
            reqTFQuestion.Display = ValidatorDisplay.Dynamic;
            reqTFQuestion.Text = "*";
            reqTFQuestion.ControlToValidate = "uxTFQuestion";
            reqTFQuestion.ErrorMessage = "No radio selection";

            //create and add list items true and false
            ListItem listTrue = new ListItem("true", "true");
            ListItem listFalse = new ListItem("False", "False");
            uxTFQuestion.Items.Add(listTrue);
            uxTFQuestion.Items.Add(listFalse);

            //add label, radio button list and validator to controls
            Controls.Add(lblTFQuestion);
            Controls.Add(uxTFQuestion);
            Controls.Add(reqTFQuestion);
        }
开发者ID:Deliv3rat0r,项目名称:CST465,代码行数:34,代码来源:TrueFalseQuestion.cs


示例7: RockDropDownList

 /// <summary>
 /// Initializes a new instance of the <see cref="RockDropDownList" /> class.
 /// </summary>
 public RockDropDownList()
 {
     RequiredFieldValidator = new RequiredFieldValidator();
     RequiredFieldValidator.ValidationGroup = this.ValidationGroup;
     HelpBlock = new HelpBlock();
     WarningBlock = new WarningBlock();
 }
开发者ID:NewSpring,项目名称:Rock,代码行数:10,代码来源:RockDropDownList.cs


示例8: CreateChildControls

        protected override void CreateChildControls()
        {
            //EnsureChildControls();
            base.CreateChildControls();
            Label lblQuestion = new Label();
            //TextBox txtQuestion = new TextBox();
            RequiredFieldValidator valQuestion = new RequiredFieldValidator();
            _txtAnswer = new TextBox();
            _txtAnswer.Text = _answer;

            lblQuestion.ID = "lbl" + _question.QuestionGuid.ToString().Replace("-", String.Empty);
            _txtAnswer.ID = "txt" + _question.QuestionGuid.ToString().Replace("-", String.Empty);
            valQuestion.ID = "val" + _question.QuestionGuid.ToString().Replace("-", String.Empty);

            lblQuestion.Text = _question.QuestionText;
            lblQuestion.AssociatedControlID = _txtAnswer.ID;

            valQuestion.ControlToValidate = _txtAnswer.ID;
            valQuestion.Enabled = _question.AnswerIsRequired;

            valQuestion.Text = _question.ValidationMessage;

            Controls.Add(lblQuestion);
            Controls.Add(_txtAnswer);
            Controls.Add(valQuestion);
        }
开发者ID:joedavis01,项目名称:mojoportal,代码行数:26,代码来源:TextBoxQuestion.cs


示例9: DynamicRadioButtonList

        public DynamicRadioButtonList()
        {
            controlXML = new DynamicRadioButtonListXml();

            _tbControls = new Table();
            _trControls = new TableRow();
            _tdLabel = new TableCell();
            _tdControl = new TableCell();
            _tdRequired = new TableCell();
            _trControls.Cells.Add(_tdLabel);
            _trControls.Cells.Add(_tdControl);
            _trControls.Cells.Add(_tdRequired);
            _tbControls.Rows.Add(_trControls);

            _radioButtonList = new RadioButtonList();
            _radioButtonList.CausesValidation = false;
            _radioButtonList.RepeatDirection = RepeatDirection.Horizontal;

            _required = new RequiredFieldValidator();
            _required.Display = ValidatorDisplay.Dynamic;
            _required.EnableClientScript = true;
            _required.Text = "*";
            _required.Enabled = false;

            _tdControl.Controls.Add(_radioButtonList);
            _tdRequired.Controls.Add(_required);
            this.Controls.Add(_tbControls);
        }
开发者ID:danilocecilia,项目名称:HulcherProject,代码行数:28,代码来源:DynamicRadioButtonList.cs


示例10: TextControl

		public TextControl(TextQuestion question)
		{
			_tb = new TextBox {CssClass = "alternative", ID = "q" + question.ID};

			if (question.Rows > 1)
			{
				_tb.TextMode = TextBoxMode.MultiLine;
				_tb.Rows = question.Rows;
			}

			if (question.Columns.HasValue)
			{
				_tb.Columns = question.Columns.Value;
			}

			_l = new Label {CssClass = "label", Text = question.Title, AssociatedControlID = _tb.ID};

			Debug.Assert(Controls != null, "Controls != null");
			Controls.Add(_l);
			Controls.Add(_tb);

			if (!question.Required) return;

			_rfv = new RequiredFieldValidator
			{
				Display = ValidatorDisplay.Dynamic,
				Text = ControlPanel.RequiredField_DefaultText,
				ErrorMessage = string.Format(ControlPanel.RequiredField_DefaultErrorMessage, question.Title),
				ControlToValidate = _tb.ID,
				ValidationGroup = "Form"
			};
			Controls.Add(_rfv);
		}
开发者ID:meixger,项目名称:n2cms,代码行数:33,代码来源:TextControl.cs


示例11: CreateChildControls

        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            Label lblQuestion = new Label();
            _dpAnswer = new DatePickerControl();
            _dpAnswer.SkinID = "Survey";
            _dpAnswer.Text = _answer;
            RequiredFieldValidator valQuestion = new RequiredFieldValidator();

            lblQuestion.ID = "lbl" + _question.QuestionGuid.ToString().Replace("-", String.Empty); ;
            _dpAnswer.ID = "dp" + _question.QuestionGuid.ToString().Replace("-", String.Empty);
            valQuestion.ID = "val" + _question.QuestionGuid.ToString().Replace("-", String.Empty);

            lblQuestion.Text = _question.QuestionText;
            lblQuestion.AssociatedControlID = _dpAnswer.ID;

            valQuestion.ControlToValidate = _dpAnswer.ID;
            valQuestion.Enabled = _question.AnswerIsRequired;

            valQuestion.Text = _question.ValidationMessage;

            Controls.Add(lblQuestion);
            Controls.Add(_dpAnswer);
            Controls.Add(valQuestion);
        }
开发者ID:saiesh86,项目名称:TravelBlog,代码行数:25,代码来源:DateQuestion.cs


示例12: GetRequiredFieldValidator

 protected RequiredFieldValidator GetRequiredFieldValidator(Control control)
 {
     var requiredFieldValidator = new RequiredFieldValidator();
     requiredFieldValidator.ControlToValidate = control.ID;
     requiredFieldValidator.SetFocusOnError = true;
     requiredFieldValidator.ErrorMessage = MandatoryErrorMessage;
     return requiredFieldValidator;
 }
开发者ID:jeppe-andreasen,项目名称:Umbraco-Public,代码行数:8,代码来源:FormsField.cs


示例13: ExibirCritica

        public void ExibirCritica(string critica)
        {
            RequiredFieldValidator validator = new RequiredFieldValidator();
            validator.ErrorMessage = critica;
            validator.IsValid = false;

            Page.Validators.Add(validator);
        }
开发者ID:ViniciusConsultor,项目名称:sistema-gestao-social,代码行数:8,代码来源:Login.aspx.cs


示例14: AddValidator

 private void AddValidator()
 {
     RequiredFieldValidator rfv = new RequiredFieldValidator();
     rfv.ID = "RequiredFieldValidator2";
     rfv.ControlToValidate   = this.TextBox2.ID;
     rfv.ErrorMessage = "Value is required for this field";
     Page.Controls.Add(rfv);
 }
开发者ID:iali,项目名称:gittest,代码行数:8,代码来源:Default.aspx.cs


示例15: CreateChildControls

        protected override void CreateChildControls()
        {
            input = new TextBox();
            input.ID="input";
            this.Controls.Add(input);
            validator=new RequiredFieldValidator();
            validator.ID="Valinput";
            validator.ControlToValidate=input.ID;

        }
开发者ID:ananth039,项目名称:Anantha-Kumar-.net-Practice-programs,代码行数:10,代码来源:RequiredTextbox.cs


示例16: HtmlEditor

        /// <summary>
        /// Initializes a new instance of the <see cref="HtmlEditor"/> class.
        /// </summary>
        public HtmlEditor()
            : base()
        {
            RequiredFieldValidator = new RequiredFieldValidator();
            RequiredFieldValidator.ValidationGroup = this.ValidationGroup;
            HelpBlock = new HelpBlock();

            TextMode = TextBoxMode.MultiLine;
            Rows = 10;
            Columns = 80;
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:14,代码来源:HtmlEditor.cs


示例17: TagsRow

		public TagsRow(TagsEditor table)
		{
			this.table = table;

			AddedList = new ListBox();
			TagButton = new Button();
			UntagButton = new Button();
			
			AddButton = new Button();
			AdditionalBox = new TextBox();
			AddValidator = new RequiredFieldValidator();
			AvailableList = new ListBox();
			Label = new Label();
		}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:14,代码来源:TagsRow.cs


示例18: CreateChildControls

        public override void CreateChildControls()
        {
            // E-mail entry text box
            _emailTextBox = new TextBox();
            _emailTextBox.ID = "_emailTextBox";
            _emailTextBox.Width = Unit.Pixel(150);
            _emailTextBox.MaxLength = 100;
            _emailTextBox.CssClass = "WebSolutionFormControl";

            // E-mail validator
            _emailValidator = new RequiredFieldValidator();
            _emailValidator.ControlToValidate = "_emailTextBox";
            _emailValidator.ErrorMessage = "You must enter a valid e-mail address.";

            // Password text box
            _passwordTextBox = new TextBox();
            _passwordTextBox.ID = "_passwordTextBox";
            _passwordTextBox.Width = Unit.Pixel(150);
            _passwordTextBox.MaxLength = 50;
            _passwordTextBox.TextMode = TextBoxMode.Password;
            _passwordTextBox.CssClass = "WebSolutionFormControl";
            _passwordTextBox.Controls.Add(_passwordTextBox);

            // Password validator
            _passwordValidator = new RequiredFieldValidator();
            _passwordValidator.ControlToValidate = "_passwordTextBox";
            _passwordValidator.ErrorMessage = "You must enter a password.";

            // Remember me check box
            _rememberMeCheckBox = new CheckBox();
            _rememberMeCheckBox.Text = "Remember me";
            _rememberMeCheckBox.CssClass = "WebSolutionFormControl";

            // Login button
            _loginButton = new Button();
            _loginButton.Text = "Login";
            _loginButton.Click += new System.EventHandler(LoginButton_Click);
            _loginButton.CssClass = "WebSolutionFormControl";

            // Add child controls to control
            Controls.Add(_emailTextBox);
            Controls.Add(_emailValidator);
            Controls.Add(_passwordTextBox);
            Controls.Add(_passwordValidator);
            Controls.Add(_rememberMeCheckBox);
            Controls.Add(_loginButton);
        }
开发者ID:dineshkummarc,项目名称:DotNetPortalSrc-102,代码行数:47,代码来源:UserLogin.cs


示例19: CreateChildControls

        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            Question = new Label();
            Question.Text = QuestionText;

            AnswerText = new TextBox();
            AnswerText.ID = "uxAnswerText";
            Controls.Add(Question);
            Controls.Add(new LiteralControl("<br/><br/>"));
            Controls.Add(AnswerText);

            RequiredFieldValidator ReqValidator = new RequiredFieldValidator();
            ReqValidator.ControlToValidate = "uxAnswerText";
            Controls.Add(ReqValidator);
        }
开发者ID:LukeeThompson,项目名称:CST465,代码行数:17,代码来源:ShortTextQuestion.cs


示例20: OnLoad

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            _requiredFieldValidator = new RequiredFieldValidator
                                          {
                                              ID = string.Format("{0}_rfv", base.ID),
                                              ControlToValidate = base.ID,
                                              Enabled = Required,
                                              Visible = Required,
                                              ErrorMessage = string.Format("{0} must not be empty.", Title),
                                              Display = ValidatorDisplay.Dynamic,
                                              ValidationGroup = base.ValidationGroup
                                          };

            _requiredFieldValidator.Controls.Add(new Literal {Text = "&nbsp;"});
            //Add error image
            _requiredFieldValidator.Controls.Add(ValidationImageHelper.GetImage(_requiredFieldValidator,
                                                                                _requiredFieldValidator.ErrorMessage));

            //Add required field validator to control
            base.Controls.Add(_requiredFieldValidator);

            _regularExpressionValidator = new RegularExpressionValidator
                                              {
                                                  ID = string.Format("{0}_rev", base.ID),
                                                  ControlToValidate = base.ID,
                                                  Enabled = ValidType != ValidationType.None,
                                                  Visible = ValidType != ValidationType.None,
                                                  ErrorMessage = ValidationHelper.GetValidationErrorMessage(ValidType),
                                                  ValidationExpression =
                                                      ValidationHelper.GetValidationExpression(ValidType),
                                                  Display = ValidatorDisplay.Dynamic,
                                                  ValidationGroup = base.ValidationGroup
                                              };

            _regularExpressionValidator.Controls.Add(new Literal {Text = "&nbsp;"});
            //Add error image
            _regularExpressionValidator.Controls.Add(ValidationImageHelper.GetImage(_regularExpressionValidator,
                                                                                    _regularExpressionValidator.
                                                                                        ErrorMessage));

            //Add required field validator to control
            base.Controls.Add(_regularExpressionValidator);
        }
开发者ID:lucaslim,项目名称:NorthBay,代码行数:45,代码来源:TextBox.cs



注:本文中的System.Web.UI.WebControls.RequiredFieldValidator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WebControls.ServerValidateEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# WebControls.RepeaterItemEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap