开发者

C# code behind Required validation

开发者 https://www.devze.com 2023-02-16 20:22 出处:网络
I am writing a c# code for aRequired field validator for a Multiline text box. I have a issue in the run time:

I am writing a c# code for a Required field validator for a Multiline text box.

I have a issue in the run time:

when i won't enter any text inside the text box

  1. For first Click on submit (Button) it shows the error message

  2. For second Click on submit it won't validate the text box and the form is submitted.

Same two issues when i even enter any text inside the text box.

Overall it is not validating...

Please help me on what could be the possible bug in the below code.

    txtReport = new InputFormTextBox();
    txtReport.TextMode = TextBoxMode.MultiLine;
    txtReport.RichText = true;
    txtReport.RichTextMode = SPRichTextMode.Compatible;
    txtReport.Rows = 5;
    txtReport.Width = new Unit(2开发者_JAVA百科00);
    txtReport.ID = "txtReport";
    txtReport.Text.Trim();
    this.Controls.Add(txtReport);


    reqVal = new RequiredFieldValidator();
    reqVal.ID = "reqVal";
    reqVal.ControlToValidate = txtReport.ID;

    reqVal.SetFocusOnError = true;
    reqVal.ErrorMessage = "*Comments field is mandatory";
    reqVal.Enabled = true;
    this.Controls.Add(reqVal);

Thanks in advance


From what it sounds like you are not re-adding the validator after the first submit, causing the second submit not to validate. But it's hard to tell from the fragment you posted (in what event/method is this being called?).

0

精彩评论

暂无评论...
验证码 换一张
取 消