Html.Span 获得span对应的HTML - HtmlSpanGet

2017-01-30 20:12:22  访问(1555) 赞(0) 踩(0)


        #region Html.Span 获得span对应的HTML - HtmlSpanGet

        /// <summary>
        /// Html.Span 获得span对应的HTML - HtmlSpanGet +
        /// </summary>
        /// <param name="strText"></param>
        /// <param name="strTitle"></param>
        /// <returns></returns>
        public string HtmlSpanGet(string strText, string strTitle)
        {
            StringBuilder theResult = new StringBuilder();

            theResult.Append("<span");

            if (strTitle != null && strTitle.Length > 0)
            {
                theResult.Append(" title=\"" + StringConvertQuot(strTitle) + "\"");
            }

            theResult.Append(">");

            if (strText != null)
            {
                theResult.Append(strText);
            }

            theResult.Append("</span>");

            return theResult.ToString();
        }
        


        /// <summary>
        /// Html.Span 获得span对应的HTML - HtmlSpanGet +
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <param name="isCursorHand"></param> 
        /// <returns></returns>
        public string HtmlSpanGet
            (
                string text,
                string title,
                bool isCursorHand
            )
        {
            StringBuilder theResult = new StringBuilder();

            theResult.Append("<span ");

            if (title != null && title.Length > 0)
            {
                theResult.Append("title=\"" + StringConvertQuot(title) + "\" ");
            }

            if (isCursorHand)
            {
                theResult.Append("style=\"cursor:pointer;\" ");
            }

            theResult.Append(">");
            
            if (text != null && text.Length > 0)
            {
                theResult.Append(text);
            }
            
            theResult.Append("</span>");

            return theResult.ToString();
        }

        /// <summary>
        /// Html.Span 获得span对应的HTML - HtmlSpanGet +
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <param name="ctrlStyle"></param>
        /// <param name="isCursorHand"></param> 
        /// <returns></returns>
        public string HtmlSpanGet
            (
                string text,
                string title,
                string ctrlStyle,
                bool isCursorHand
            )
        {
            StringBuilder theResult = new StringBuilder();

            theResult.Append("<span ");

            if (title != null && title.Length > 0)
            {
                theResult.Append("title=\"" + StringConvertQuot(title) + "\" ");
            }

            if (ctrlStyle == null || ctrlStyle.Length == 0)
            {
                if (isCursorHand)
                    theResult.Append("style=\"cursor:pointer;\" ");
            }
            else
            {
                if (isCursorHand)
                    theResult.Append("style=\"cursor:pointer;" + ctrlStyle + "\" ");
                else
                    theResult.Append("style=\"" + ctrlStyle + "\" ");
            }

            theResult.Append(">");

            if (text != null && text.Length > 0)
            {
                theResult.Append(text);
            }

            theResult.Append("</span>");

            return theResult.ToString();
        }


        /// <summary>
        /// Html.Span 获得span对应的HTML - HtmlSpanGet +
        /// </summary>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <param name="isCursorHand"></param>
        /// <param name="onClick"></param>
        /// <returns></returns>
        public string HtmlSpanGet
            (
                string text,
                string title,
                bool isCursorHand,
                string onClick
            )
        {
            StringBuilder theResult = new StringBuilder();

            theResult.Append("<span ");

            if (title != null && title.Length > 0)
            {
                theResult.Append("title=\"" + StringConvertQuot(title) + "\" ");
            }

            if (isCursorHand)
                theResult.Append("style=\"cursor:pointer;\" ");

            if (onClick != null && onClick.Length != 0)
            {
                theResult.Append("onclick=\"" + StringConvertQuot(onClick) + "\" ");
            }

            theResult.Append(">");


            if (text != null && text.Length > 0)
            {
                theResult.Append(text);
            }

            theResult.Append("</span>");

            return theResult.ToString();
        }

        /// <summary>
        /// Html.Span 获得span对应的HTML - HtmlSpanGet +
        /// </summary>
        /// <param name="strId"></param>
        /// <param name="text"></param>
        /// <param name="title"></param>
        /// <param name="isCursorHand"></param>
        /// <param name="onClick"></param>
        /// <param name="cssClass"></param>
        /// <returns></returns>
        public string HtmlSpanGet
            (
                string strId,
                string text,
                string title,
                bool isCursorHand,
                string onClick,
                string cssClass
            )
        {
            StringBuilder theResult = new StringBuilder();

            theResult.Append("<span ");

            if (strId != null && strId.Length > 0)
            {
                theResult.Append("id=\"" + StringConvertQuot(strId) + "\" ");
            }

            if (title != null && title.Length > 0)
            {
                theResult.Append("title=\"" + StringConvertQuot(title) + "\" ");
            }


            if (cssClass != null && cssClass.Length > 0)
            {
                theResult.Append("class=\"" + StringConvertQuot(cssClass) + "\" ");
            }

            if (isCursorHand)
                theResult.Append("style=\"cursor:pointer;\" ");

            if (onClick != null && onClick.Length != 0)
            {
                theResult.Append("onclick=\"" + StringConvertQuot(onClick) + "\" ");
            }

            theResult.Append(">");


            if (text != null && text.Length > 0)
            {
                theResult.Append(text);
            }

            theResult.Append("</span>");

            return theResult.ToString();
        }




        #endregion Html.Span 获得span对应的HTML - HtmlSpanGet


标签:创建span 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)
 
  ┈全部┈  
 
(显示默认分类)