获得带a点击弹出的图片 - GetHrefImage

2017-04-10 13:53:14  访问(1629) 赞(0) 踩(0)



        /// <summary>
        /// 获得带a点击弹出的图片 - GetHrefImage +
        /// </summary>
        /// <param name="imgUrl"></param>
        /// <returns></returns>
        public static string GetHrefImage
            (
                string imgUrl
            )
        {
            if(imgUrl == null)
                return "";

            string convertImgUrl = StringSlowXFunctions.ConvertStringQuot(imgUrl);

            StringBuilder theResult = new StringBuilder();

            theResult.Append("<a");
            theResult.Append(" href=\"" +convertImgUrl  + "\"");
            theResult.Append(" target=\"_blank\"");
            theResult.Append(">");
            theResult.Append("<img");
            theResult.Append(" src=\"" + convertImgUrl + "\"");
            theResult.Append(" border=\"0\"");
            theResult.Append(" alt=\"\"");
            theResult.Append(" />");
            theResult.Append("</a>");

            return theResult.ToString();
        }

        /// <summary>
        /// 获得带a点击弹出的图片 - GetHrefImage +
        /// </summary>
        /// <param name="imgUrl"></param>
        /// <returns></returns>
        public static string GetHrefImage
            (
                string imgUrl,
                int width,
                int height,
                string imgTitle
            )
        {
            if (imgUrl == null)
                return "";

            string convertImgUrl = StringSlowXFunctions.ConvertStringQuot(imgUrl);
            imgTitle = StringSlowXFunctions.ConvertStringQuot(imgTitle);

            StringBuilder theResult = new StringBuilder();

            StringBuilder imgStyle = new StringBuilder();
            imgStyle.Append("border:0px;");
            // width:350px; height:260px; border:0px;
            if (width > 0)
                imgStyle.Append("width:" + width.ToString() + "px;");

            if (height > 0)
                imgStyle.Append("height:" + height.ToString() + "px;");

            theResult.Append("<a");
            theResult.Append(" href=\"" + convertImgUrl + "\"");
            theResult.Append(" target=\"_blank\"");
            theResult.Append(" title=\"" + imgTitle + "\"");
            theResult.Append(">");
            theResult.Append("<img");
            theResult.Append(" src=\"" + convertImgUrl + "\""); 
            theResult.Append(" alt=\"" + imgTitle + "\"");
            theResult.Append(" style=\"" + imgStyle.ToString() + "\"");


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

            return theResult.ToString();
        }


标签:获得带a点击弹出的图片 - GetHrefImage 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

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