IHtmlGenerator.GenerateValidationMessage 方法

定義

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

public:
 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 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
Public 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 屬性的實例。

傳回

備註

ValidationMessageElement 預設為 "span"

適用於