1
我正在爲Multiline文本框編寫一個必填字段驗證器的c#代碼。後面的C#代碼需要驗證
我在運行時的問題:它
的時候我不會進入 文本框中
內的任何文本,首先點擊提交(按鈕)顯示錯誤信息
對於第二個點擊提交它不會驗證文本框並提交表單。
兩個相同的問題時,我甚至輸入在文本框內任何 文本。
整體而言,這是沒有驗證...
請幫我,這可能是在下面的代碼可能的錯誤。
txtReport = new InputFormTextBox();
txtReport.TextMode = TextBoxMode.MultiLine;
txtReport.RichText = true;
txtReport.RichTextMode = SPRichTextMode.Compatible;
txtReport.Rows = 5;
txtReport.Width = new Unit(200);
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);
在此先感謝
你把'.CausesValidation'屬性設置爲'true'嗎? – 2011-03-14 07:54:50
@KMan,我已經在按鈕屬性中給出button.CausesValidation = true; – Jam 2011-03-14 08:01:19