2
有人可以幫助我將下面的剃刀語法轉換爲它的等效vb.net razor語法嗎?將C#Razor語法轉換爲VB.NET Razor
@(Html.Kendo().Menu()
.Name("menu") //The name of the menu is mandatory. It specifies the "id" attribute of the widget.
.BindTo(Model, mappings =>
{
mappings.For<category>(binding => binding //define first level of menu
.ItemDataBound((item, category) => //define mapping between menu item properties and the model properties
{
item.Text = category.CategoryName;
})
.Children(category => category.Products)); //define which property of the model contains the children
mappings.For<product>(binding => binding
.ItemDataBound((item, product) =>
{
item.Text = product.ProductName;
}));
})
) --update
我必須設法轉換成部分,上面的代碼,但現在收到以下錯誤:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30561: 'Html' is ambiguous, imported from the namespaces or types 'System.Web.WebPages, System.Web.Mvc, Kendo.Mvc.UI'.
Source Error:
Line 2: @ModelType IEnumerable(Of MenuCategory)
Line 3:
Line 4: @(Html.Kendo().Menu() _
Line 5: .Name("TestMenu") _
Line 6: .BindTo(Model, Sub(mappings)
Source File: C:\Documents and Settings\vivekba\my documents\visual studio 2010\Projects\test\test\Views\Home\TestMenu.vbhtml Line: 4
我轉換視圖看起來像這樣
@Imports test.Models
@ModelType IEnumerable(Of TestMenuCategory)
@(Html.Kendo().Menu() _
.Name("TestMenu") _
.BindTo(Model,
Sub(mappings)
mappings.For(Of TestMenuCategory)(
Sub(x)
x.ItemDataBound(
Sub(item, menu)
item.Text = menu.Name
End Sub) _
.Children(
Function(menu)
Return menu.SubItem
End Function)
mappings.For(Of TestMenuItem)(Sub(bindings)
bindings.ItemDataBound(Sub(testItem, menuItem)
testItem.Text = "test"
End Sub)
End Sub)
End Sub)
End Sub)
)
或引導我在正確的方向上如何轉換它? – Baahubali 2013-05-07 02:33:47
語法依賴於@ {do domething}塊。您可以訪問VB對象。如果那是你所問的。 – 2013-05-07 02:34:27
我知道。我已經嘗試在vb.net中重寫這個,但在ItemDataBound(item,category)上我怎麼能重寫呢? Visual Studio也不提供任何智能感知幫助 – Baahubali 2013-05-07 02:40:28