0
是將字符串(此字符串可以更改幷包含asp-route -...屬性)轉換爲html屬性列表的方式嗎?剃刀引擎應該使用所有的asp-route -...屬性來轉換爲正確的url。我有以下代碼,但不起作用。將字符串轉換爲html屬性
@{
var Attributes = ViewData["Attributes"] as Dictionary<string,string>;
var AttributeRoute = "";
@foreach (var key in Attributes.Keys)
{
AttributeRoute += "asp-route-"+key+"=\""+Attributes[key]+"\" ";
}
}
...
@AttributeRoute #Prints output (ex. asp-route-testkey="testvalue")
<a class='item' @AttributeRoute>test</a> #Doesn't print the list of attributes