共用方式為


DefaultValidationHtmlAttributeProvider.AddValidationAttributes 方法

定義

如果已啟用用戶端驗證, attributes 則會將驗證相關的 HTML 屬性新增至 。

public:
 override void AddValidationAttributes(Microsoft::AspNetCore::Mvc::Rendering::ViewContext ^ viewContext, Microsoft::AspNetCore::Mvc::ViewFeatures::ModelExplorer ^ modelExplorer, System::Collections::Generic::IDictionary<System::String ^, System::String ^> ^ attributes);
public override void AddValidationAttributes (Microsoft.AspNetCore.Mvc.Rendering.ViewContext viewContext, Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer modelExplorer, System.Collections.Generic.IDictionary<string,string> attributes);
override this.AddValidationAttributes : Microsoft.AspNetCore.Mvc.Rendering.ViewContext * Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer * System.Collections.Generic.IDictionary<string, string> -> unit
Public Overrides Sub AddValidationAttributes (viewContext As ViewContext, modelExplorer As ModelExplorer, attributes As IDictionary(Of String, String))

參數

viewContext
ViewContext

ViewContext目前範圍的實例。

modelExplorer
ModelExplorer

ModelExplorer運算式的 。

attributes
IDictionary<String,String>

Dictionary<TKey,TValue> 接收驗證屬性的 。 將驗證屬性名稱對應至其 String 值。 值必須經過 HTML 編碼,才能寫入 HTML 檔案或回應。

適用於