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 9008825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:02:08+00:00 2026-06-16T02:02:08+00:00

I have an ASP.NET link button that I need to add both text and

  • 0

I have an ASP.NET link button that I need to add both text and an image to I thought I would be able to just add the image to the button using Controls.Add but no dice.

Here is what I have so far:

foreach (var entity in metadata.Meta.Where(e => e.ReportableObject == true))
{
    LinkButton lb = new LinkButton();
    string iconpath = "~/images/search/" + entity.ClassName + ".png";
    lb.CssClass = "entityIcon";
    lb.Controls.Add(new Image { ImageUrl =  iconpath , CssClass = "imgSize"});
    lb.Text = entity.ClassName;
    entityHolder.Controls.Add(lb);
}

When the control renders I see the text but I’m not even getting an image container rendered. I thought it might have been the path to the image but even when I tried to map to a image from an existing site using the full qualified path nothing would render.

Edit: For clarification there are no asp.net controls in the main page (link or image) this for loop is iterating a collection and creating the controls at runtime. The last line entityHolder is a ASP.NET panel that the buttons are added to.

Can someone help me understand what I am doing wrong if this is even possible. I have to use a LinkButton and not an ImageButton as I need to render both text and image.

Cheers

  • 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-06-16T02:02:10+00:00Added an answer on June 16, 2026 at 2:02 am

    You would have to do it manipulating the Text property of the control to also render the <img tag for example:

    foreach (var entity in metadata.Meta.Where(e => e.ReportableObject == true))
    {
          LinkButton lb = new LinkButton();
          string iconpath = ResolveClientUrl("~/images/search/" + entity.ClassName + ".png");
          lb.CssClass = "entityIcon";
          lb.Text = string.Format(@"image <img src=""{0}"" class=""{1}"" />",iconpath,"imgSize");
          entityHolder.Controls.Add(lb);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use yui datatable in my asp.net application... I have a link button in
In my ASP .NET MVC application i have a link that refreshes the preview
I have a asp.net link button and i have applied below css on it
I have a asp.net user control, I added a image button and then in
I have a button on my asp.net page that (upon mouseover) needs to act
I'm using Fancybox 1.3.4 with ASP.NET MVC 3. I have following link : <a
I have asp.net TextBox with ontextchanged event this is search text box in my
I have ASP.Net code generating my button's HTML for me using divs to get
Just beginning my journey in ASP.Net MVC and I have a query about something
I have a LinkButton click event in asp.net 3.5 that I must assess whether

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.