【发布时间】:2012-03-04 18:32:36
【问题描述】:
我希望从我的代码隐藏中完成以下格式:
<a href="">
<img src=""/>
</a>
我已经这样做了,但我无法将图像添加到<a href>
谁能告诉我该怎么做?
这是我的代码:
Dim urls As New List(Of String)
urls.Add("Downloads/" & Session("tempDir").ToString & "/" & filename)
For Each imageURL As String In urls
Dim img = New System.Web.UI.WebControls.Image()
img.ImageUrl = imageURL
img.Attributes.Add("src", "Downloads/" & Session("tempDir").ToString & "/" & filename)
img.Attributes.Add("rel", "group2")
img.Width = 75
img.Height = 50
img.CssClass = "clickImage"
img.ImageAlign = HorizontalAlign.Left
Me.FinalPreview.Controls.Add(img)
Next
我发现了这个:
Dim anchor As New HtmlGenericControl("a")
anchor.Attributes.Add("href", "#")
但我无法理解如何向其中添加 img 如果我添加控件,则总 img 不会显示。
【问题讨论】:
标签: asp.net html vb.net image href