Share via


DefaultHtmlGenerator.GenerateValidationMessage 方法

定義

如果 viewContextModelState 包含 的錯誤 expression ,則產生 tag 專案。

public:
 virtual Microsoft::AspNetCore::Mvc::Rendering::TagBuilder ^ GenerateValidationMessage(Microsoft::AspNetCore::Mvc::Rendering::ViewContext ^ viewContext, Microsoft::AspNetCore::Mvc::ViewFeatures::ModelExplorer ^ modelExplorer, System::String ^ expression, System::String ^ message, System::String ^ tag, System::Object ^ htmlAttributes);
public virtual Microsoft.AspNetCore.Mvc.Rendering.TagBuilder GenerateValidationMessage (Microsoft.AspNetCore.Mvc.Rendering.ViewContext viewContext, Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer modelExplorer, string expression, string message, string tag, object htmlAttributes);
abstract member GenerateValidationMessage : Microsoft.AspNetCore.Mvc.Rendering.ViewContext * Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer * string * string * string * obj -> Microsoft.AspNetCore.Mvc.Rendering.TagBuilder
override this.GenerateValidationMessage : Microsoft.AspNetCore.Mvc.Rendering.ViewContext * Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer * string * string * string * obj -> Microsoft.AspNetCore.Mvc.Rendering.TagBuilder
Public Overridable Function GenerateValidationMessage (viewContext As ViewContext, modelExplorer As ModelExplorer, expression As String, message As String, tag As String, htmlAttributes As Object) As TagBuilder

參數

viewContext
ViewContext

ViewContext目前範圍的實例。

modelExplorer
ModelExplorer

ModelExplorerexpression

expression
String

相對於目前模型的運算式名稱。

message
String

要顯示的訊息。 如果 null 為 或空白,方法會從 ModelStateDictionary 物件擷取錯誤字串。 訊息一律會顯示,但用戶端驗證可能會更新相關聯的 CSS 類別。

tag
String

要包裝 message 在所產生 HTML 中的 標記。 其預設值為 ValidationMessageElement

htmlAttributes
Object

Object,其中包含 專案的 HTML 屬性。 或者, IDictionary<TKey,TValue> 包含 HTML 屬性的實例。

傳回

實作

適用於