コード例 #1
0
        public static MvcHtmlString ActionLink(this HtmlHelper helper, string LinkText, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary <string, object> htmlAttributes, bool generateToken)
        {
            RequestContext  rc           = helper.ViewContext.RequestContext;
            RouteCollection rtCollection = helper.RouteCollection;

            if (generateToken == true)
            {
                string token = TokenUtility.generateUrlToken(controllerName, actionName, routeValues, tokenPassword);
                routeValues.Add("urltoken", token);
            }
            string        link    = HtmlHelper.GenerateLink(rc, rtCollection, LinkText, null, actionName, controllerName, protocol, hostName, fragment, routeValues, htmlAttributes);
            MvcHtmlString mString = MvcHtmlString.Create(link);

            return(mString);
        }
コード例 #2
0
        public static MvcHtmlString ActionLink(this HtmlHelper helper, string LinkText, string actionName, string controllerName, bool generateToken)
        {
            RequestContext       rc           = helper.ViewContext.RequestContext;
            RouteCollection      rtCollection = helper.RouteCollection;
            RouteValueDictionary rvd          = new RouteValueDictionary();

            if (generateToken == true)
            {
                string token = TokenUtility.generateUrlToken(controllerName, actionName, rvd, tokenPassword);
                rvd.Add("urltoken", token);
            }
            string        link    = HtmlHelper.GenerateLink(rc, rtCollection, LinkText, null, actionName, controllerName, rvd, null);
            MvcHtmlString mString = MvcHtmlString.Create(link);

            return(mString);
        }
コード例 #3
0
        //This is the extended method of Html.ActionLink.This class has the extended methods for the 10 overloads of this method
        //All the overloaded method applys the same logic excepts the parameters passed in
        public static MvcHtmlString ActionLink(this HtmlHelper helper, string LinkText, string actionName, bool generateToken)
        {
            RequestContext       rc           = helper.ViewContext.RequestContext;
            RouteCollection      rtCollection = helper.RouteCollection;
            RouteValueDictionary rvd          = new RouteValueDictionary();

            if (generateToken == true)
            {
                //Call the generateUrlToken method which create the hash
                string token = TokenUtility.generateUrlToken("", actionName, rvd, tokenPassword);
                //The hash is added to the route value dictionary
                rvd.Add("urltoken", token);
            }
            //the link is formed by using the GenerateLink method.
            string        link    = HtmlHelper.GenerateLink(rc, rtCollection, LinkText, null, actionName, null, rvd, null);
            MvcHtmlString mString = MvcHtmlString.Create(link);

            return(mString);
        }
コード例 #4
0
        public static MvcHtmlString ActionLink(this HtmlHelper helper, string LinkText, string actionName, object routeValues, object htmlAttributes, bool generateToken)
        {
            RequestContext       rc           = helper.ViewContext.RequestContext;
            RouteCollection      rtCollection = helper.RouteCollection;
            RouteValueDictionary rvd          = new RouteValueDictionary(routeValues);

            if (generateToken == true)
            {
                string token = TokenUtility.generateUrlToken("", actionName, rvd, tokenPassword);
                rvd.Add("urltoken", token);
            }
            IDictionary <string, object> attrib;

            attrib = getDictionaryFromObject(htmlAttributes);
            //attrib.Add("attributes", htmlAttributes);
            string        link    = HtmlHelper.GenerateLink(rc, rtCollection, LinkText, null, actionName, null, rvd, attrib);
            MvcHtmlString mString = MvcHtmlString.Create(link);

            return(mString);
        }