Пример #1
0
        public IHtmlString ActionLink(string linkText, string actionName, string controllerName = "", object routeValues = null, object htmlAttributes = null)
        {
            var qs = UrlHelper.GenerateQueryString(routeValues);

            if (qs.Length > 0)
            {
                qs = "?" + qs;
            }

            return(new HtmlString(string.Format("<a href=\"{0}{1}{2}{3}\"{4}>{5}</a>",
                                                ViewBase.UrlScheme,
                                                string.IsNullOrEmpty(controllerName) ? String.Empty : controllerName + "/",
                                                actionName,
                                                qs,
                                                GenerateHtmlAttributes(htmlAttributes),
                                                linkText)));
        }
Пример #2
0
        public MvcForm BeginForm(string actionName = "", string controllerName = "", object routeValues = null, FormMethod method = FormMethod.Get, object htmlAttributes = null)
        {
            var qs = UrlHelper.GenerateQueryString(routeValues);

            if (qs.Length > 0)
            {
                qs = "?" + qs;
            }

            var form = String.Format("<form action=\"{0}{1}{2}{3}\" method=\"{4}\"{5}>",
                                     ViewBase.UrlScheme,
                                     String.IsNullOrEmpty(controllerName) ? String.Empty : controllerName + "/",
                                     actionName,
                                     qs,
                                     method == FormMethod.Post ? "post" : "get",
                                     GenerateHtmlAttributes(htmlAttributes));

            _writer.Write(form);
            return(new MvcForm(_writer, "form"));
        }