How to set WebForm HyperLink ImageAlign Property

Last post 07-04-2009 5:06 PM by logikonlineinc. 2 replies.

Sort Posts:

  • How to set WebForm HyperLink ImageAlign Property

    08-26-2005, 9:55 PM
    • Member
      170 point Member
    • xenoak47
    • Member since 11-05-2003, 5:35 PM
    • Vancouver, BC
    • Posts 36
    I use Hyperlink images a lot on my site, and was wondering if there is a way I set the ImageAlign property for the image? I know that you can do it with a normal Image control, but there is no such property exposed with the Hyperlink control. Any items added to the Attributes collection end up as attributes of the hyperlink and not the image.

    Any ideas would be much appreciated.

    Thanks,
    Allen K.

    There are 10 types of people in this world: those that understand binary and those that don't.
  • Re: How to set WebForm HyperLink ImageAlign Property

    09-14-2008, 10:06 PM
    • Member
      376 point Member
    • Mar7in
    • Member since 08-05-2008, 4:20 PM
    • AB, Canada
    • Posts 68

    This is a rather old post which went unanswered. I ran into similar situation and I ended up override RenderContents:  

    protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
    {
        string imageUrl = this.ImageUrl;
        if (imageUrl.Length > 0)
        {
            Image image = new Image();
            image.ImageUrl = base.ResolveClientUrl(imageUrl);
            image.ImageAlign = ImageAlign.AbsMiddle;
            imageUrl = this.ToolTip;
            if (imageUrl.Length != 0)
            {
                image.ToolTip = imageUrl;
            }
            imageUrl = this.Text;
            if (imageUrl.Length != 0)
            {
                image.AlternateText = imageUrl;
            }
            image.RenderControl(writer);
        }
        else
        {
            writer.Write(this.Text);
        }
    }
     
    Please Mark the post as "Answer" if it solves your problem.

    http://www.dotnetsharp.com/
  • Re: How to set WebForm HyperLink ImageAlign Property

    07-04-2009, 5:06 PM

    Microsoft... Can you please add this to the Hyperlink object.  While I can override like the gentlemen above suggests - in existing projects it makes it difficult to replace all instances.

    This is a simple addition on your end.

    regards,
    Dave

Page 1 of 1 (3 items)