2013-05-07 129 views
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) 
     ) 
+0

或引导我在正确的方向上如何转换它? – Baahubali 2013-05-07 02:33:47

+0

语法依赖于@ {do domething}块。您可以访问VB对象。如果那是你所问的。 – 2013-05-07 02:34:27

+0

我知道。我已经尝试在vb.net中重写这个,但在ItemDataBound(item,category)上我怎么能重写呢? Visual Studio也不提供任何智能感知帮助 – Baahubali 2013-05-07 02:40:28

回答

1

这是修复如果有人在寻找。

@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 = menuItem.name 
                          End Sub) 
                   End Sub) 



         End Sub) 
      End Sub) 
    )