RenderBeginTag and RenderEndTag can render a surrounding tag around the image you generated. This could be a table or a div that surrounds it.
Brian
"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4).
BogN
Member
130 Points
36 Posts
Adapter For Asp:Image Control
Jul 14, 2006 01:24 PM|LINK
What are the: RenderBeginTag, RenderEndTag and RenderContents methods?
I will explain what i want to do:
MyAspxPage.aspx
<asp:image id="myImage" runat="server" cssSelectorClass="myClass" src="pig.jpg" alt="bla bla bla" />
HTML source:
<img id="myImage" class="myClass" src="pig.jpg" alt="blablabla" />
I wrote this code:
public class ImageAdapter : WebControlAdapter
{
Image image;
protected override void RenderContents(HtmlTextWriter writer)
{
Image image = Control as Image;
if ((image != null) &&
(image.Attributes["CssSelectorClass"] != null) &&
(image.Attributes["CssSelectorClass"].Length > 0))
{
writer.Indent++;
writer.WriteBeginTag("img");
writer.WriteAttribute("src", Page.ResolveUrl(image.ImageUrl));
writer.WriteAttribute("alt", image.ToolTip);
writer.WriteAttribute("class", image.Attributes["CssSelectorClass"]);
writer.Write(HtmlTextWriter.SelfClosingTagEnd);
writer.Indent--;
writer.WriteLine();
}
}
protected override void RenderBeginTag(HtmlTextWriter writer)
{
//
}
protected override void RenderEndTag(HtmlTextWriter writer)
{
//
}
}
, but why did i implenet only the RenderContents method? which method i should implement for my purpose?
bmains
All-Star
29116 Points
5886 Posts
MVP
Re: Adapter For Asp:Image Control
Jul 14, 2006 01:37 PM|LINK
Hey,
RenderBeginTag and RenderEndTag can render a surrounding tag around the image you generated. This could be a table or a div that surrounds it.
"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4).
BogN
Member
130 Points
36 Posts
Re: Adapter For Asp:Image Control
Jul 14, 2006 04:35 PM|LINK