当前位置: 首页>>代码示例>>C#>>正文


C# this.ActionLink方法代码示例

本文整理汇总了C#中this.ActionLink方法的典型用法代码示例。如果您正苦于以下问题:C# this.ActionLink方法的具体用法?C# this.ActionLink怎么用?C# this.ActionLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在this的用法示例。


在下文中一共展示了this.ActionLink方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProductActions

        public static string ProductActions(this HtmlHelper html, ProductoDTO producto, bool isDGAA)
        {
            var actions = String.Empty;

            if ((isDGAA && producto.IsFirmed()) || (!isDGAA && producto.IsValidated()))
                actions += String.Format("<span>{0}</span>",
                                         html.ActionLink("Editar", "Edit", "Home",
                                         	new { id= producto.Id, tipoProducto = producto.TipoProducto }, null));
            else if (!isDGAA)
            {
                if (!producto.IsFirmed() && !producto.IsValidated() && producto.UsuarioId == producto.CurrentUserId)
                {
                    actions += String.Format("<span>{0}</span>",
                                         html.ActionLink("Editar", "Edit", "Home",
                                         	new { id= producto.Id, tipoProducto = producto.TipoProducto }, null));

                    actions += String.Format("<span>{0}</span>",
                                         html.ActionLink("Firmar", "Sign", "Home",
                                         	new { id= producto.Id, tipoProducto = producto.TipoProducto }, new { @class = "remote put"}));
                }
                else if (producto.IsFirmed() && !producto.IsValidated() || producto.UsuarioId != producto.CurrentUserId)
                {
                    actions += String.Format("<span>{0}</span>",
                                         html.ActionLink("Ver", "Show", "Home",
                                         	new { id= producto.Id, tipoProducto = producto.TipoProducto }, null));
                }
            }
            return actions;
        }
开发者ID:sesquiv,项目名称:siacvu,代码行数:29,代码来源:ProductoHelper.cs

示例2: DisplayNameForSort

        public static IHtmlString DisplayNameForSort(this AjaxHelper helper, string displayName, string columName, string actionName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, string controllerName = null)
        {
            if (!string.IsNullOrWhiteSpace(columName))
            {
                string orderBy;
                string iconName;
                HtmlHelperExtensions.GetListOrderParams(columName, out orderBy, out iconName);
                if (routeValues.ContainsKey("orderBy"))
                {
                    routeValues["orderBy"] = orderBy;
                }
                else
                {
                    routeValues.Add("orderBy", orderBy);
                }

                MvcHtmlString link;
                if (string.IsNullOrEmpty(controllerName))
                {
                    link = helper.ActionLink(displayName, actionName, routeValues, ajaxOptions);
                }
                else
                {
                    link = helper.ActionLink(displayName, actionName, controllerName, routeValues, ajaxOptions);
                }

                string htmlStr = "<div class=\"ap-sortedHeader\">{0}<i class=\"ap-sortedHeader fa {1}\"></i></div>";
                return new MvcHtmlString(string.Format(htmlStr, link.ToString(), iconName));
            }
            else
            {
                return new MvcHtmlString(displayName);
            }
        }
开发者ID:dfensgmbh,项目名称:biz.dfch.CS.Appclusive.UI,代码行数:34,代码来源:AjaxHelperExtensions.cs

示例3: MenuLink

 public static MvcHtmlString MenuLink(
  this HtmlHelper htmlHelper,
  string linkText,
  string actionName,
  string controllerName,
  string tooltip = "")
 {
     string currentAction = htmlHelper.ViewContext.RouteData.GetRequiredString("action");
      string currentController = htmlHelper.ViewContext.RouteData.GetRequiredString("controller");
      if (controllerName == "Home" && actionName=="Index")
      {
     return MenuLinkForMessages(htmlHelper, linkText, actionName, controllerName, tooltip);
        }
      if (actionName == currentAction && controllerName == currentController)
      {
     string classForElement = "currentMenuItem";
     return htmlHelper.ActionLink(
         linkText,
         actionName,
         controllerName,
         null,
         new
         {
            @class = classForElement
         });
      }
      return htmlHelper.ActionLink(linkText, actionName, controllerName);
 }
开发者ID:abmobilesoftware,项目名称:txtFeedback,代码行数:28,代码来源:LinkHelper.cs

示例4: PagingNavigator

        public static MvcHtmlString PagingNavigator(this AjaxHelper helper, int pageNum, int itemsCount, int pageSize)
        {
            StringBuilder sb = new StringBuilder();
            AjaxOptions ao = new AjaxOptions {UpdateTargetId = "BooksDiv"};

            if (pageNum > 0)
            {
                sb.Append(helper.ActionLink("<", "Index","Books", new { pageNum = pageNum - 1 },ao));
            }
            else
            {
                sb.Append(HttpUtility.HtmlEncode("<"));
            }
            sb.Append(" ");

            int pagesCount = (int)Math.Ceiling((double)itemsCount / pageSize);

            if (pageNum < pagesCount - 1)
            {
                sb.Append(helper.ActionLink(">", "Index","Books", new { pageNum = pageNum + 1 },ao));
            }
            else
            {
                sb.Append(HttpUtility.HtmlEncode(">"));
            }

            return MvcHtmlString.Create(sb.ToString());
        }
开发者ID:BSBYarek,项目名称:_TY_REP,代码行数:28,代码来源:Paging.cs

示例5: BlogPager

        public static string BlogPager(this HtmlHelper helper, IPagedList pager)
        {
            // Don't display anything if not multiple pages
            if (pager.TotalPageCount == 1)
                return string.Empty;

            // Build route data
            var routeData = new RouteValueDictionary(helper.ViewContext.RouteData.Values);

            // Build string
            var sb = new StringBuilder();

            // Render Newer Entries
            if (pager.PageIndex > 0)
            {
                routeData["page"] = pager.PageIndex - 1;
                sb.Append(helper.ActionLink("Newer Entries", "Index", routeData));
            }

            // Render divider
            if (pager.PageIndex > 0 && pager.PageIndex < pager.TotalPageCount - 1)
                sb.Append(" | ");

            // Render Older Entries
            if (pager.PageIndex < pager.TotalPageCount - 1)
            {
                routeData["page"] = pager.PageIndex + 1;
                sb.Append(helper.ActionLink("Older Entries", "Index", routeData));
            }

            return sb.ToString();
        }
开发者ID:bjeverett,项目名称:asp-net-mvc-unleashed,代码行数:32,代码来源:BlogPagerHelper.cs

示例6: MenuItem

 public static MvcHtmlString MenuItem(this HtmlHelper htmlHelper, string text, string action, string controller, int? categoryId = null, string cssClasses = null)
 {
     var li = new TagBuilder("li");
     var routeData = htmlHelper.ViewContext.RouteData;
     var currentAction = routeData.GetRequiredString("action");
     var currentController = routeData.GetRequiredString("controller");
     if (string.Equals(currentAction, action, StringComparison.OrdinalIgnoreCase) &&
         string.Equals(currentController, controller, StringComparison.OrdinalIgnoreCase))
     {
         li.AddCssClass("active");
     }
     if (!string.IsNullOrEmpty(cssClasses))
     {
         li.AddCssClass(cssClasses);
     }
     if (categoryId != null)
     {
         li.InnerHtml = htmlHelper.ActionLink(text, action, controller,new { id = categoryId.Value },new {}).ToHtmlString();
     }
     else
     {
         li.InnerHtml = htmlHelper.ActionLink(text, action, controller).ToHtmlString();
     }
     return MvcHtmlString.Create(li.ToString());
 }
开发者ID:Icestorm0141,项目名称:portfolio,代码行数:25,代码来源:MenuExtensions.cs

示例7: PrettyJoin

        public static MvcHtmlString PrettyJoin(this HtmlHelper html, IEnumerable<Person> persons)
        {
            int count = 0;
            string res = "";

            foreach (var person in persons)
            {
                switch (++count)
                {
                    case 1:
                        res = html.ActionLink(person.Name, "Details", "Person", new { id = person.PersonId }, null).ToString();
                        break;

                    case 2:
                        res = html.ActionLink(person.Name, "Details", "Person", new { id = person.PersonId }, null).ToString() + " og " + res;
                        break;

                    default:
                        res = html.ActionLink(person.Name, "Details", "Person", new { id = person.PersonId }, null).ToString() + ", " + res;
                        break;
                }
            }

            return MvcHtmlString.Create(res);
        }
开发者ID:ProgramUtvikling,项目名称:MSU2015,代码行数:25,代码来源:MyHtmlHelpers.cs

示例8: MenuItem

 public static MvcHtmlString MenuItem(this HtmlHelper htmlHelper, string text, string action, string controller, object routeValues = null, object htmlAttributes = null)
 {
     var li = new TagBuilder("li");
     var routeData = htmlHelper.ViewContext.RouteData;
     var currentAction = routeData.GetRequiredString("action");
     var currentController = routeData.GetRequiredString("controller");
     if (string.Equals(currentAction, action, StringComparison.OrdinalIgnoreCase) || string.Equals(currentController, controller, StringComparison.OrdinalIgnoreCase))
     {
         li.AddCssClass("active");
     }
     if (routeValues != null)
     {
         li.InnerHtml = (htmlAttributes != null)
             ? htmlHelper.ActionLink(text,
                                     action,
                                     controller,
                                     routeValues,
                                     htmlAttributes).ToHtmlString()
             : htmlHelper.ActionLink(text,
                                     action,
                                     controller,
                                     routeValues).ToHtmlString();
     }
     else
     {
         li.InnerHtml = htmlHelper.ActionLink(text,
                                              action,
                                              controller).ToHtmlString();
     }
     return MvcHtmlString.Create(li.ToString());
 }
开发者ID:dayewah,项目名称:crisischeckin,代码行数:31,代码来源:MenuExtensions.cs

示例9: SiteMenu

        public static MvcHtmlString SiteMenu(this HtmlHelper helper, Tenant currentTenant)
        {
            ILinkService linkService = DependencyResolver.Current.GetService<ILinkService>();
            if (currentTenant == null || linkService == null)
            {
                return null;
            }

            TagBuilder itemTag;
            IList<Link> menuItems = linkService.GetMenuLinks(currentTenant.Id.ToString());
            TagBuilder menu = new TagBuilder("ul");

            menu.MergeAttribute("id", "menu");
            foreach (Link item in menuItems)
            {
                itemTag = new TagBuilder("li");
                if (String.IsNullOrWhiteSpace(item.Area))
                {
                    itemTag.InnerHtml = helper.ActionLink(item.Name, item.Action, new { area = "", controller = item.Controller }).ToString();
                }
                else
                {
                    itemTag.InnerHtml = helper.ActionLink(item.Name, item.Action, new { area = item.Area, controller = item.Controller }).ToString();
                }
                menu.InnerHtml += itemTag;
            }
            return MvcHtmlString.Create(menu.ToString());
        }
开发者ID:jcadruvi,项目名称:MultiTenant,代码行数:28,代码来源:HtmlHelperExtentions.cs

示例10: BuildBreadcrumbNavigation

        public static string BuildBreadcrumbNavigation(this HtmlHelper helper)
        {
            // optional condition: I didn't wanted it to show on home and account controller
            if (helper.ViewContext.RouteData.Values["controller"].ToString() == "Home" ||
                helper.ViewContext.RouteData.Values["controller"].ToString() == "Account")
            {
                return string.Empty;
            }

            StringBuilder breadcrumb = new StringBuilder("<div class=\"breadcrumb\"><li>").Append(helper.ActionLink("Home", "Index", "Home").ToHtmlString()).Append("</li>");

            breadcrumb.Append("<li>");
            breadcrumb.Append(helper.ActionLink(helper.ViewContext.RouteData.Values["controller"].ToString(),
                                               "Index",
                                               helper.ViewContext.RouteData.Values["controller"].ToString()));
            breadcrumb.Append("</li>");

            if (helper.ViewContext.RouteData.Values["action"].ToString() != "Index")
            {
                breadcrumb.Append("<li>");
                breadcrumb.Append(helper.ActionLink(helper.ViewContext.RouteData.Values["action"].ToString(),
                                                    helper.ViewContext.RouteData.Values["action"].ToString(),
                                                    helper.ViewContext.RouteData.Values["controller"].ToString()));
                breadcrumb.Append("</li>");
            }

            return breadcrumb.Append("</div>").ToString();
        }
开发者ID:learningcraft2015,项目名称:DemoControls,代码行数:28,代码来源:ApplicationHelpers.cs

示例11: LoginLink

        public static string LoginLink(this HtmlHelper helper)
        {
            string currentControllerName = (string)helper.ViewContext.RouteData.Values["controller"];
            string currentActionName = (string)helper.ViewContext.RouteData.Values["action"];
            bool isAuthenticated = helper.ViewContext.HttpContext.Request.IsAuthenticated;

            var sb = new StringBuilder();
            if (isAuthenticated)
            {
                sb.Append("Logged in as <span>");
                sb.Append(helper.ViewContext.HttpContext.User.Identity.Name);
                sb.Append("</span>");
            }

            sb.Append("<div id=\"loginlink\"");

            if (currentControllerName.Equals("Account", StringComparison.CurrentCultureIgnoreCase) && (currentActionName.Equals("Login", StringComparison.CurrentCultureIgnoreCase) || currentActionName.Equals("Logout", StringComparison.CurrentCultureIgnoreCase)))
                sb.Append(" class=\"selected\">");
            else
                sb.Append(">");

            if (isAuthenticated)
            {
                sb.Append(helper.ActionLink("Logout", "Logout", "Account"));
            }
            else
            {
                sb.Append(helper.ActionLink("Login", "Logon", "Account"));
            }
            sb.Append("</div>");
            return sb.ToString();
        }
开发者ID:etuannv,项目名称:TNVTH,代码行数:32,代码来源:LoginLinkHelper.cs

示例12: Pager

        /// <summary>
        /// The pager.
        /// </summary>
        /// <param name="helper">
        /// The helper.
        /// </param>
        /// <param name="action">
        /// The action.
        /// </param>
        /// <param name="pageIndex">
        /// The page index.
        /// </param>
        /// <param name="pageSize">
        /// The page size.
        /// </param>
        /// <param name="totalRecords">
        /// The total records.
        /// </param>
        /// <returns>
        /// The System.String.
        /// </returns>
        public static string Pager(this HtmlHelper helper, string action, int pageIndex, int pageSize, int totalRecords)
        {
            string html = string.Empty;
            int pageCount = (totalRecords % pageSize == 0) ? (totalRecords / pageSize) : (totalRecords / pageSize) + 1;
            for (int idx = 1; idx <= pageCount; idx++)
            {
                if (idx - 1 == pageIndex)
                {
                    html += idx.ToString() + " ";
                }
                else
                {
                    if (idx == 1)
                    {
                        html += helper.ActionLink(idx.ToString(), action);
                    }
                    else
                    {
                        html += helper.ActionLink(idx.ToString(), action, new { id = idx - 1, page = idx - 1 });
                    }

                    html += " ";
                }
            }

            return html;
        }
开发者ID:pickup,项目名称:PickupBlog,代码行数:48,代码来源:PagerExtension.cs

示例13: MenuLinkListItem

        public static MvcHtmlString MenuLinkListItem(
                this HtmlHelper htmlHelper,
                string linkText,
                string actionName,
                string controllerName,
                bool isAdmin = false
            )
        {
            string currentController = htmlHelper.ViewContext.RouteData.GetRequiredString("controller");

            var li = new TagBuilder("li");

            if (controllerName == currentController)
            {
                li.AddCssClass("active");
            }

            if (isAdmin)
            {
                li.InnerHtml = htmlHelper.ActionLink(linkText, actionName, controllerName, new { area = MVC.Admin.Name }, null).ToHtmlString();
            }
            else
            {
                li.InnerHtml = htmlHelper.ActionLink(linkText, actionName, controllerName).ToHtmlString();
            }

            return new MvcHtmlString(li.ToString());
        }
开发者ID:v-zmiycharov,项目名称:aVelev,代码行数:28,代码来源:HtmlExtensions.cs

示例14: MenuItem

        public static MvcHtmlString MenuItem(this HtmlHelper html, string actionName,
            string controllerName,string unselectedCss,string selectedCss, 
            string menuCaption,string tagName = "div",IDictionary<string,object> htmlAttributes = null, 
            string permissionName = "",bool isVisible = true,object routeValues = null)
        {
            if (isVisible)
            {
                bool canUserSeeItem = false;
                if (!String.IsNullOrWhiteSpace(permissionName))
                {
                    //TODO : check here visibility of menu item by permission check
                    canUserSeeItem = false;
                }
                else
                {
                    canUserSeeItem = true;
                }

                if (canUserSeeItem == true)
                {
                    string selectionString = String.Empty;
                    string selectionCssClass = String.Empty;
                    if (html.ViewContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString().Equals(controllerName, StringComparison.OrdinalIgnoreCase) && html.ViewContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString().Equals(controllerName, StringComparison.OrdinalIgnoreCase))
                    {
                        selectionString = "true";
                        selectionCssClass = selectedCss;
                    }
                    else
                    {
                        selectionCssClass = unselectedCss;
                        selectionString = "false";
                    }

                    string itemControl = String.Empty;
                    if (routeValues == null)
                    {
                        itemControl = String.Format(@"
                                                    <{3} class='{2} MenuItem' data-isSelected='{1}'>
                                                        {0}
                                                    </{3}>
                                                   ", html.ActionLink(menuCaption, actionName, controllerName),
                                                            selectionString, selectionCssClass, tagName);
                    }
                    else
                    {
                        itemControl = String.Format(@"
                                                    <{3} class='{2} MenuItem' data-isSelected='{1}'>
                                                        {0}
                                                    </{3}>
                                                   ", html.ActionLink(menuCaption, actionName, controllerName,routeValues,null),
                                                            selectionString, selectionCssClass, tagName);
                    }

                    return MvcHtmlString.Create(itemControl);
                }
            }
            return MvcHtmlString.Create("");
        }
开发者ID:AndrejMikhalev,项目名称:quartz-master,代码行数:58,代码来源:Menu.cs

示例15: CreatePostLink

 public static MvcHtmlString CreatePostLink(this HtmlHelper html, Thread thread)
 {
     string txt = thread.IsLocked ? "Locked" : "Create Post";
     string cssClass = thread.IsLocked ? "img_link create-post-locked" : "img_link create-post";
     if (thread.IsLocked)
         return html.ActionLink(txt, "ViewThread", "Board", new { ThreadID = thread.ThreadID }, new { @class = cssClass });
     else
         return html.ActionLink(txt, "CreatePost", "Post", new { ThreadID = thread.ThreadID }, new { @class = cssClass });
 }
开发者ID:harikrishnanvr,项目名称:mesoBoard,代码行数:9,代码来源:Thread.cs


注:本文中的this.ActionLink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。