J
James T.
Hello!
I developed a composite control that inherits from HyperLink and overrides
Render method.
In web form I am using this control with DataGrid. On DataGrid ItemDataBound
event I set ImageWidth and ImageHeight values programmatically. But on
post-back the control loses ImageWidth and ImageHeight values.
What I am doing wrong?
Thank you!
James
CODE:
-----------------------
Protected Overrides Sub Render(ByVal Output As System.Web.UI.HtmlTextWriter)
Output.AddAttribute(HtmlTextWriterAttribute.Href, Me.NavigateUrl)
Output.RenderBeginTag(HtmlTextWriterTag.A)
If ImageUrl.Length = 0 Then
Output.Write([Text])
Else
Output.AddAttribute(HtmlTextWriterAttribute.Src, ImageUrl)
Output.AddAttribute(HtmlTextWriterAttribute.Alt, [Text])
Output.AddAttribute(HtmlTextWriterAttribute.Height, ImageHeight)
Output.AddAttribute(HtmlTextWriterAttribute.Width, ImageWidth)
If Not (ImageHeight Is Nothing) Then
Output.AddAttribute(HtmlTextWriterAttribute.Height, ImageHeight)
End If
If Not (ImageWidth Is Nothing) Then
Output.AddAttribute(HtmlTextWriterAttribute.Width, ImageWidth)
End If
Output.RenderBeginTag(HtmlTextWriterTag.Img)
Output.RenderEndTag()
End If
Output.RenderEndTag()
End Sub
I developed a composite control that inherits from HyperLink and overrides
Render method.
In web form I am using this control with DataGrid. On DataGrid ItemDataBound
event I set ImageWidth and ImageHeight values programmatically. But on
post-back the control loses ImageWidth and ImageHeight values.
What I am doing wrong?
Thank you!
James
CODE:
-----------------------
Protected Overrides Sub Render(ByVal Output As System.Web.UI.HtmlTextWriter)
Output.AddAttribute(HtmlTextWriterAttribute.Href, Me.NavigateUrl)
Output.RenderBeginTag(HtmlTextWriterTag.A)
If ImageUrl.Length = 0 Then
Output.Write([Text])
Else
Output.AddAttribute(HtmlTextWriterAttribute.Src, ImageUrl)
Output.AddAttribute(HtmlTextWriterAttribute.Alt, [Text])
Output.AddAttribute(HtmlTextWriterAttribute.Height, ImageHeight)
Output.AddAttribute(HtmlTextWriterAttribute.Width, ImageWidth)
If Not (ImageHeight Is Nothing) Then
Output.AddAttribute(HtmlTextWriterAttribute.Height, ImageHeight)
End If
If Not (ImageWidth Is Nothing) Then
Output.AddAttribute(HtmlTextWriterAttribute.Width, ImageWidth)
End If
Output.RenderBeginTag(HtmlTextWriterTag.Img)
Output.RenderEndTag()
End If
Output.RenderEndTag()
End Sub