Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 894707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:26:18+00:00 2026-05-15T14:26:18+00:00

Possible Duplicate: Text on an Image button in c# asp.net 3.5 I want a

  • 0

Possible Duplicate:
Text on an Image button in c# asp.net 3.5

I want a asp.net button with text on left and image on right

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:26:19+00:00Added an answer on May 15, 2026 at 2:26 pm

    Here’s one I wrote:

    public class WebImageButton : LinkButton, IButtonControl
    {
        protected override void OnPreRender(EventArgs e)
        {
            if (!this.DesignMode)
            {
                // Apply the image
                if (this.Image.Length > 0)
                {
                    this.Style.Add("background-image", "url(" + this.Image + ")");
                    this.Style.Add("background-repeat", "no-repeat");
                    this.Style.Add("background-position", this.ImageHorizontalOffset + " " + this.ImageVerticalOffset);
                }
            }
    
            base.OnPreRender(e);
        }
    
        [DescriptionAttribute("The path to the default image to be displayed.")]
        public string Image
        {
            get
            {
                if (_image == null)
                {
                    return string.Empty;
                }
                return _image;
            }
            set
            {
                _image = value;
            }
        }
        private string _image;
    
        [DescriptionAttribute("The unit to offset the image by horizontally.")]
        public string ImageHorizontalOffset
        {
            get
            {
                return _imageHorizontalOffset;
            }
            set
            {
                _imageHorizontalOffset = value;
            }
        }
        private string _imageHorizontalOffset = "0px";
    
        [DescriptionAttribute("The unit to offset the image by vertically.")]
        public string ImageVerticalOffset
        {
            get
            {
                return _imageVerticalOffset;
            }
            set
            {
                _imageVerticalOffset = value;
            }
        }
        private string _imageVerticalOffset = "center";
    
    }   
    

    Then the CSS that accompanies it:

    .ImageButton
    {
        background:#666;
        border:solid 1px #000;
        color:#FFF;
        font-size:10pt;
        font-weight:bold;
        padding:4px;
        text-align:center;
        cursor:hand;
    }
    

    And an example of its use:

    <ctrl:WebImageButton ID="WebImageButton1" runat="server"
        OnClick="WebImageButton1_Click" CssClass="ImageButton" Text="Click me" 
        ImageHorizontalOffset="4px" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Multiline text in JLabel I want to do this: JLabel myLabel =
Possible Duplicate: Asp.net how to correct the error I'm designing my web page using
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions
Possible Duplicate: Convert HTML to PDF in .NET I am using VSTS 2008 +
Possible Duplicate: Parsing text in C Say I have written to a text file
Possible Duplicate: How do I get this CSS text-decoration issue to work? I'm using
Possible Duplicate: Using Emacs to recursively find and replace in text files not already
Possible Duplicate: Determine a string's encoding in C# Many text editorsr (like Notepad++) can
Possible Duplicate: Mac text/code editor What's your favorite Code Editor or IDE for Mac
Possible Duplicate: How To Set Text In An EditText how can we assign value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.