简体   繁体   中英

How to add parameters in url.content

I try create dynamic menu but i have problem with adding parameters in link to the controller and action, can i add parameter to url.content? or there are the other way please give your insight it will very helpfull

<nav class="navbar navbar-inverse">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">Menu Example</a>
        </div>
        <ul class="nav navbar-nav">
            @if (Session["Menu"] != null)
            {

                var MenuMaster = (List<Accountstatement.Models.MenuModel>)Session["Menu"];
                var groupByMenu = MenuMaster.GroupBy(x => x.MainMenuName).ToList();

                foreach (var MenuList in groupByMenu)
                {

                    <li class="dropdown">
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">@MenuList.Key<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            @foreach (var SubMenuList in MenuList)
                            {
                                <li><a href="@Url.Content("~/"+@SubMenuList.ControllerName +"/"+ @SubMenuList.ActionName")">@SubMenuList.SubMenuName</a></li>
                            }
                        </ul>
                    </li>

                }
            }

        </ul>

this is the part the url.content is, how can i put the parameter inside url.content?

<li><a href="@Url.Content("~/"+@SubMenuList.ControllerName +"/"+ @SubMenuList.ActionName")">@SubMenuList.SubMenuName</a></li>

Use @Html.Raw with Url.Content and pass parameters like below:

@Html.Raw(Url.Content("~/"+@SubMenuList.ControllerName +"/"+ @SubMenuList.ActionName?param=" + param.value))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM