Hi, I am confused how this should be implemented.
I want to use the Attributes.Add("OnClick", "value goes here...") in the codebehind and I am confused if I need to add the code for the render part?
Example, I want to add the attributes.add name and value on the anchor control:
1 Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
2 'output.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference(Me, String.Empty))
3 If ImagePosition = ImagePositionModes.left Then
4 If String.IsNullOrEmpty(Url) = False Then
5 output.AddAttribute(HtmlTextWriterAttribute.Href, Url)
6 If TargetSelection <> Nothing Then
7 output.AddAttribute(HtmlTextWriterAttribute.Target, TargetSelection.ToString)
8 ElseIf TargetString <> String.Empty Then
9 output.AddAttribute(HtmlTextWriterAttribute.Target, TargetString.ToString)
10 End If
11 output.AddAttribute(HtmlTextWriterAttribute.Title, LinkTitle)
12 output.AddAttribute(HtmlTextWriterAttribute.Class, CssClass)
add the rendered attributes.add code here?????
13 output.RenderBeginTag(HtmlTextWriterTag.A)
14 End If
15 If String.IsNullOrEmpty(ImgUrl) = False Then
16 output.AddAttribute("name", UniqueID)
17 output.AddAttribute(HtmlTextWriterAttribute.Align, TextPosition.ToString)
18 output.AddAttribute(HtmlTextWriterAttribute.Src, ImgUrl)
19 output.AddAttribute(HtmlTextWriterAttribute.Border, "0")
20 output.AddAttribute(HtmlTextWriterAttribute.Alt, ImageTitle)
21 output.AddAttribute(HtmlTextWriterAttribute.Width, Width.ToString)
22 output.AddAttribute(HtmlTextWriterAttribute.Height, Height.ToString)
23 output.RenderBeginTag(HtmlTextWriterTag.Img)
24 End If
Thanks for any help with this.