R
Ric_C
Greetings, all...
I'm having some issues with extending the
System.Web.UI.WebControls.Button. I want to add an image to the button
that will render on the button face itself. Think of the 'Back' button
for the IE browser - and image to the left of the text.
Unfortunately, with what I've coded, I'm getting exactly what I would
expect: an image to the left of the text. The problem is, the image is
rendering off the face of the button.
What I need to find out is how to add the new image to part of the
base, instead of as a new control that renders before the base.
Here's the code I've got so far:
namespace GoofingAround
{
[DefaultProperty("ImageUrl"),
ToolboxData("<{0}:TextImageButton
runat=server></{0}:TextImageButton>")]
public class TextImageButton : System.Web.UI.WebControls.Button,
INamingContainer
{
private Image _imageUrl = new Image();
[Bindable(false),
Category("Appearance"),
Description("The image to be added to the button.")]
public string ImageUrl
{
get{return _imageUrl.ImageUrl;}
set{_imageUrl.ImageUrl = value;}
}
protected override void Render(HtmlTextWriter writer)
{
_imageUrl.RenderControl(writer);
writer.Write(" ");
base.Render(writer);
}
}
}
The goal is to programmatically change the text based on localization
or custom strings, as well as being able to change the image.
Any help would be greatly appreciated!
thanks,
Ric
I'm having some issues with extending the
System.Web.UI.WebControls.Button. I want to add an image to the button
that will render on the button face itself. Think of the 'Back' button
for the IE browser - and image to the left of the text.
Unfortunately, with what I've coded, I'm getting exactly what I would
expect: an image to the left of the text. The problem is, the image is
rendering off the face of the button.
What I need to find out is how to add the new image to part of the
base, instead of as a new control that renders before the base.
Here's the code I've got so far:
namespace GoofingAround
{
[DefaultProperty("ImageUrl"),
ToolboxData("<{0}:TextImageButton
runat=server></{0}:TextImageButton>")]
public class TextImageButton : System.Web.UI.WebControls.Button,
INamingContainer
{
private Image _imageUrl = new Image();
[Bindable(false),
Category("Appearance"),
Description("The image to be added to the button.")]
public string ImageUrl
{
get{return _imageUrl.ImageUrl;}
set{_imageUrl.ImageUrl = value;}
}
protected override void Render(HtmlTextWriter writer)
{
_imageUrl.RenderControl(writer);
writer.Write(" ");
base.Render(writer);
}
}
}
The goal is to programmatically change the text based on localization
or custom strings, as well as being able to change the image.
Any help would be greatly appreciated!
thanks,
Ric