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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:07:27+00:00 2026-06-17T11:07:27+00:00

I’ve been looking about and cant figure out how to get a value from

  • 0

I’ve been looking about and cant figure out how to get a value from C# into the tag on an ASPX page. I’ve tried a number of options but not getting anywhere.

When my asp page loads, a value is obtained using queryString from the pages url (i.e. mypage.aspx?app=safety )
It then runs a switch to find out what image url to use on the page.

Thing is, I get a Compilation Error “The name ‘img_small’ does not exist in the current context”. What do you think of my code below? I cant see what Im missing!

C#:

protected void Page_Load(object sender, EventArgs e)
{
    string img_small;

    String appName = Request.QueryString["app"];

    switch (appName)
    {
        case "safety":
            img_small = "safety-logo.png";
            break;

        case "files":
            img_small = "files-logo.png";
            break;

        case "drawings":
            img_small = "drawings-logo.png";
            break;

        case "specs":
            img_small = "specs-logo.png";
            break;

        default:
            img_small = "idms-logo.png";
            break;
    }
}

HTML:

<img src='"<%=img_small%>"' />
  • 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-17T11:07:28+00:00Added an answer on June 17, 2026 at 11:07 am

    This is because img_small is a local variable of Page_Load function, it doesn’t exist outside this function. This is why you get this error.

    I’d suggested you to change

    <img src='"<%=img_small%>"' />
    

    to

    <asp:Image ID='imgImage' runat='server' />
    

    And then at the bottom of Page_Load function do

    imgImage.ImageUrl = img_small;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am currently running into a problem where an element is coming back from
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.