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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:19:55+00:00 2026-06-01T00:19:55+00:00

Placing an image inside a Span (here : HtmlGenericControl ) programmatically Want to have

  • 0

Placing an image inside a Span (here : HtmlGenericControl ) programmatically
Want to have a process on it later via the FindControl

        HtmlGenericControl spnMeta = new HtmlGenericControl("span") 
            { ID = "spanMeta" };
        //Literal litMeta = new Literal();
        //litEdit.Text = "<span id=\"spanMeta\" class=\"meta\" runat=\"server\">" ;

        Image imgCodeIcon = new Image()
        {
            ID="imgCodeIcon" ,
            ImageUrl="../Images/Code-icon.gif" ,
            Width = 15 , Height = 11 
        };
        spnMeta.Controls.Add(imgCodeIcon);
        // Shouldn't be important here ...
        spnMeta.DataBinding +=new EventHandler(spnMeta_DataBinding);

        // closing Span if Literal is used

Doing this way will have no effect :

spnMeta.Controls.Add(imgCodeIcon);

and image will be rendered outside of the span and next to it

Formerly I made the procedure via Literal as it’s commented out in the below code block
but that time seemed I can not access to it from server code

how could I achieve this ?

  • 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-01T00:19:57+00:00Added an answer on June 1, 2026 at 12:19 am

    Here is some sample code to place an image into a placeholder via code:

    ASPX

    <div>
        <asp:PlaceHolder ID="ph1" runat="server"></asp:PlaceHolder>
    </div>
    

    C#

            HtmlGenericControl spnMeta = new HtmlGenericControl("span") { ID = "spanMeta" };
            Image imgCodeIcon = new Image()
            {
                ID = "imgCodeIcon",
                ImageUrl = "../Images/Code-icon.gif",
                Width = 15,
                Height = 11
            };
            spnMeta.Controls.Add(imgCodeIcon);
            ph1.Controls.Add(spnMeta);
    

    This is the output:

    <div>
        <span id="spanMeta"><img id="imgCodeIcon" src="../Images/Code-icon.gif" style="height:11px;width:15px;" /></span>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am placing a templated Button with some content in inside it (both Image
I have a listbox with images inside it. I want a horizontal row of
i have a background image on a webpage and i am placing an image
I am placing a vertical image into a square UIImageView. It gets centered inside
I am new to JS and I have a pretty simple-seeming problem. I want
I am creating a UITextField programmatically and placing it inside a UIView. The font
i am working on displaying an image and placing an icon on top of
I've been playing image generation on ImageMagick on Ubuntu 9.10. I want to be
i'm placing a automatic redirect on my Classic ASP page (vb). i want to
I am facing a problem in placing an image for an UIBarButtonItem. This is

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.