示例#1
0
        /// <summary>
        /// Column header in a list/grid which is not sortable
        /// </summary>
        public static string ColHead(string title)
        {
            HtmlTag html = new HtmlTag("div");

            html.Add("class", "colhead");
            html.SetInnerHtml(title);
            return(html.ToString());
        }
示例#2
0
        /// <summary>
        /// Returns a string containing an HTML IMG tag, given a SRC attribute (ie relative URL to image file), alt text and css class.
        /// Returns empty string (ie no tag) if imageSrc is null.
        /// </summary>
        /// <param name="imageSrc">this should include the attachments folder if required</param>
        /// <param name="altText"></param>
        /// <param name="cssClass"></param>
        /// <returns></returns>
        public static string Image(string imageSrc, string altText, string cssClass, int?width, int?height)
        {
            string result = "";

            if (imageSrc.IsNotBlank())
            {
                var html = new HtmlTag("img");
                html.Add("src", imageSrc, false);
                html.AddIfNotBlank("alt", altText);
                html.AddIfNotBlank("class", cssClass);
                if (width != null)
                {
                    html.Add("width", width.ToString());
                }
                if (height != null)
                {
                    html.Add("height", height.ToString());
                }
                result = html.ToString();
            }
            return(result);
        }
示例#3
0
        /// <summary>
        /// Sortable column header in a list/grid
        /// </summary>
        public static string ColSort(string fieldName, string title, string currentSortField, bool isDescending)
        {
            if (title == null)
            {
                title = Fmt.SplitTitleCase(fieldName);
                if (title.StartsWith("Is "))
                {
                    title = title.Substring(3);
                }
            }

            if (fieldName == "SortPosition")
            {
                isDescending = false;
            }

            HtmlTag html = new HtmlTag("a");

            html.Add("href", "javascript:ColSortBy(" + fieldName.JsEnquote() + ")");
            html.Add("title", "sort by " + title.JsEnquote() + "");
            string css = "colhead colsort";

            if (currentSortField == fieldName)
            {
                css += " selected";
                if (isDescending)
                {
                    css += " descending";
                }
                else
                {
                    css += " ascending";
                }
            }
            html.Add("class", css);

            html.SetInnerHtml(title);
            return(html.ToString());
        }