예제 #1
0
        public static MvcForm BeginForm(this HtmlHelper htmlHelper, FormMethod formMethod, object htmlAttributes)
        {
            // generates <form action="{current url}" method="post">...</form>
            string formAction = htmlHelper.ViewContext.HttpContext.Request.RawUrl;

            return(FormHelper(htmlHelper, formAction, formMethod, MrCMSHtmlHelperExtensions.AnonymousObjectToHtmlAttributes(htmlAttributes)));
        }
예제 #2
0
        private static string GetCacheKey(string prefix, string imageUrl, Size targetSize, string alt = null, string title = null, object attributes = null)
        {
            var stringBuilder = new StringBuilder(prefix + imageUrl);

            if (targetSize != default(Size))
            {
                stringBuilder.AppendFormat(";size:{0},{1}", targetSize.Width, targetSize.Height);
            }
            if (!string.IsNullOrWhiteSpace(alt))
            {
                stringBuilder.AppendFormat(";alt:{0}", alt);
            }
            if (!string.IsNullOrWhiteSpace(title))
            {
                stringBuilder.AppendFormat(";title:{0}", title);
            }
            if (!string.IsNullOrWhiteSpace(title))
            {
                stringBuilder.AppendFormat(";title:{0}", title);
            }
            if (attributes != null)
            {
                var routeValueDictionary = MrCMSHtmlHelperExtensions.AnonymousObjectToHtmlAttributes(attributes);
                foreach (var kvp in routeValueDictionary)
                {
                    stringBuilder.AppendFormat(";{0}:{1}", kvp.Key, kvp.Value);
                }
            }

            return(stringBuilder.ToString());
        }
예제 #3
0
        public static MvcForm BeginForm <T>(this HtmlHelper htmlHelper, FormMethod formMethod, object htmlAttributes) where T : Webpage, IUniquePage
        {
            string formAction = "/" +
                                htmlHelper.ViewContext.HttpContext.Get <IUniquePageService>()
                                .GetUniquePage <T>()
                                .LiveUrlSegment;

            return(FormHelper(htmlHelper, formAction, formMethod, MrCMSHtmlHelperExtensions.AnonymousObjectToHtmlAttributes(htmlAttributes)));
        }