target属性不适用于C#文字字符串,请给我另一种方法。下面是附加的html
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
byte[] bytes = (byte[])rdr["stock_pic"];
string strBase64 = Convert.ToBase64String(bytes);
Image1.ImageUrl = "data:Image/png;base64," + strBase64;
carName=rdr["carName"].ToString();
Literal1.Text = Literal1.Text + "<tr><td>" + carName + "</td><td><a href="+Image1.ImageUrl+" target='_blank'>View</a></td></tr>";
}
<table id="example1" class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th>Stock No</th>
<th>Stock picture</th>
</tr>
</thead>
<tbody>
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
<asp:Image ID="Image1" Height="100px" Width="100px" runat="server" />
</tbody>
</table>
答案 0 :(得分:1)
您需要在图片网址附近加引号。
Literal1.Text = Literal1.Text + "<tr><td>" + carName + "</td><td><a href='"+Image1.ImageUrl+"' target='_blank'>View</a></td></tr>";
答案 1 :(得分:0)
您缺少“ image1.imageurl”周围的引号。