0
我對其中包含以下工作的代碼<select>
元件的正常工作標籤助手:TagHelperAttribute.Value是字符串類型,而不是鍵入ModelExpression,新型標籤
TagHelperAttribute forAttribute;
if (!context.AllAttributes.TryGetAttribute("asp-for", out forAttribute))
{
throw new Exception("No asp-for attribute found.");
}
var forInfo = (Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression)forAttribute.Value;
我有相同的代碼在不同的標籤助手,我打電話給<date-picker>
。在這第二個標籤幫手,投給ModelExpression
失敗,因爲forAttribute.Value
是,其實不是ModelExpression
而是一個字符串(這是屬性名,「交貨期」,對此我想要的標籤綁定)。
看起來我的小說date-picker
標記不知道asp-for
值應該應用於Razor頁面模型。
如何確保我的date-picker
收到正確的ModelExpression
,以此爲基礎輸出?