簡體   English   中英

在asp.net中RequiredFieldValidator Text和ErrorMessage有什么區別?

[英]In asp.net RequiredFieldValidator What is difference between Text and ErrorMessage?

在asp.net中RequiredFieldValidator Text和ErrorMessage屬性有什么區別?

文本:驗證失敗時顯示的消息。

ErrorMessage:驗證失敗時在ValidationSummary控件中顯示的文本。 注意:如果未設置Text屬性,則此文本也將顯示在驗證控件中。

參考: http//www.w3schools.com/aspnet/control_reqfieldvalidator.asp

ErrorMessage屬性顯示在ValidationSummary控件中。 文本顯示在controlToValidate旁邊。 如果將“顯示”屬性設置為“無”,則不會顯示“文本”。

在正常設置中,text屬性顯示在驗證器旁邊,錯誤消息顯示在ValidationSummary中。

Text和ErrorMessage都用於顯示錯誤消息。 但請記住,如果您使用的是Text屬性,那么在驗證摘要中將不會顯示任何內容。 要在validationSummary中顯示錯誤,必須使用ErrorMessage。 如果你想在文本框前面顯示錯誤信息,那么兩者都是一樣的。 如果你使用兩者,那么在Text中優先顯示文本消息前面的錯誤消息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM