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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:25:56+00:00 2026-05-11T10:25:56+00:00

I have a bunch of images on my ASP.NET page like so: for (int

  • 0

I have a bunch of images on my ASP.NET page like so:

for (int i = 0; i < 3; i++) {     Image image = new Image();     image.ID = 'UpdateStatus';     image.CssClass = 'imageCss';     image.ImageUrl = 'Bump.GIF';     this.Controls.Add(image); } 

I want to loop through each image.

Why does this not work? i.e. ‘Function 1’ is outputted but ‘Function 2’ is not

$(document.body).click(function () {     console.log('Function 1');      $('imageCss').each(function(){         console.log('Function 2');     }); }); 

Why does this not work? i.e. ‘Function 1’ is outputted and ‘Function 2’ outputted ONCE. Why not 3 times?

$(document.body).click(function () {     console.log('Function 1');      $(''#UpdateStatus'').each(function(){         console.log('Function 2');     }); }); 

This works fine BUT i cannot access ‘this’, it is NULL. I need to be able to reference the current image.

$(document.body).click(function () {     console.log('Function 1');      $.each('#UpdateStatus', function() { //Or when I use 'imageCss'         console.log('Function 2');                 console.log(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. 2026-05-11T10:25:56+00:00Added an answer on May 11, 2026 at 10:25 am

    (1) Your jQuery call $('imageCss') isn’t a valid selector. You need to prefix the classname with ‘.’ to denote that you want to select elements with the class ‘imageCss’:

    $('.imageCss')

    (2) IDs must be unique. When you set Control.ID = ‘foo’ on the server in ASP.NET, that is setting the server-side ID of the control. The client-side ID generated in the HTML will be a unique, long, ugly string like ctl00_ctl01_pnlMain_foo1. Your best option is to use class selectors. You can apply multiple classes to a single element by using a space to separate them:

    myImage.CssClass = 'image otherclass'; 

    Both $('.image') and $('.otherclass') will correctly select the element.

    (3) this does not exist because of closures. Functions are executed in the context of the object that invokes the function, so this will be that object.

    Or, in your case it doesn’t really look like your function is executing within the context of any object, so I’m not sure what you’re expecting this to be.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer The half answer is to set the IsDocumentEnabled property on… May 11, 2026 at 11:30 am
  • added an answer From my experience, you can get this to work 'good… May 11, 2026 at 11:30 am
  • added an answer ExternalInterface works by allowing JavaScript to invoke an ActionScript function… May 11, 2026 at 11:30 am

Related Questions

I have a ListBox with a bunch of images in it (done through a
I have a web page that includes a bunch of images. Sometimes the image
I have a bunch of files that I need to be able to transport
I have a bunch of latitude/longitude pairs that map to known x/y coordinates on
I have a bunch of .NET frameworks installed on my machine. I know that
I have a bunch of classes I want to rename. Some of them have
I have a bunch of perfmon files that have captured information over a period
I have a bunch of PDF files and my Perl program needs to do
I have a bunch of reports that are printed out and mailed to clients.
I have a bunch of java files from which I want to remove the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.