将html标记放在图像标记的title属性中(图像标记中的文本格式)

时间:2013-03-15 16:24:47

标签: asp.net

using (SqlConnection conn = DataAccess.GetConnected())
        {
            SqlCommand cmd = new SqlCommand("GetImageForSlider", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader sqr = cmd.ExecuteReader();
            while (sqr.Read())
            {
                string image_path = sqr.GetString(0);
                string description = sqr.GetString(1);
                string action = sqr.GetString(2);
                HtmlImage += "<img src=\"" + image_path + "\" title=\"" + "<h3>" + description + action + "\".</h3><p><br></p><ahref=http://www.giftotravels.com >Thisislink</a>" + "/>";

            }
        }

我正在尝试如上,但这不能正常工作 任何人都可以帮忙???

2 个答案:

答案 0 :(得分:1)

您无法在图片标记内插入html标记;它变成无效的格式。你想像这样呈现html。

HtmlImage += string.Format("<img src=\"{0}\" title=\"/><h3>{1}{2}.</h3>" +
   "<p><br></p><a href='http://www.giftotravels.com'>Thisislink</a>", 
    image_path, description, action);

答案 1 :(得分:0)

你做不到。 title属性呈现为纯文本。如果你想做文本标记,自己创建一个元素,让它在鼠标悬停时漂浮在图片上方。

相关问题