Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 将动态内容添加到_Layout.vbhtml_Asp.net Mvc_Vb.net - Fatal编程技术网

Asp.net mvc 将动态内容添加到_Layout.vbhtml

Asp.net mvc 将动态内容添加到_Layout.vbhtml,asp.net-mvc,vb.net,Asp.net Mvc,Vb.net,最后从web表单转到MVC 因此,在我的main _Layout.vbhtml中,我有一个如下菜单: <a href="#" class="has-arrow"><i class="material-icons">person</i> Account</a> <ul> <li>

最后从web表单转到MVC

因此,在我的main _Layout.vbhtml中,我有一个如下菜单:

                        <a href="#" class="has-arrow"><i class="material-icons">person</i> Account</a>
                        <ul>
                            <li><a href="account-signin.aspx">Sign In / Sign Up</a></li>
                            <li><a href="account-profile.aspx">Profile Page</a></li>
                            <li><a href="account-orders.aspx">Orders List</a></li>
                            <li><a href="account-order-detail.aspx">Order Detail</a></li>
                            <li><a href="account-wishlist.aspx" class="has-badge">Wishlist <span class="badge badge-primary badge-pill">3</span></a></li>
                            <li><a href="account-address.aspx">Address</a></li>
                        </ul>

我希望现在从数据库中动态地获取这些信息

在web表单世界中,这将是一个母版页,然后我将添加一个文本,然后在代码后面的页面加载中填充它


但是我现在如何在MVC中归档相同的内容呢

最后在_layout.html中完成了这项工作,但不确定这是否是正确的方式:-)

@代码 Dim listGroups作为列表(ProductGroups的)=ProductGroups.MenuList() 结束代码

然后再往下看:

                    <li>
                        <a href="#" class="has-arrow"><i class="material-icons">shopping_cart</i> Shop</a>
                        <ul>
                            @For Each item In listGroups
                                @<li><a href="@Html.DisplayFor(Function(modelItem) item.GroupURL)" title="@Html.DisplayFor(Function(modelItem) item.Group)">@Html.DisplayFor(Function(modelItem) item.Group)</a></li>
                            Next
                        </ul>
                    </li>
    • @对于列表组中的每个项目 @
    • 下一个

  • 正如我所说,这是我所期望的,但不确定您的“假设”是否就是这样做的?

    很多例子都是这样的。创建另一个视图,然后添加控制器,从数据库中吐出几行html,这似乎是一个巨大的开销:-(虽然MVC应该可以改进,但它的代码量是web表单的三倍……我对COBOL也说过同样的话:)这只是普通的MVC。还有更高级的解决方案,比如或javascript库(我们使用Kendo)。