Solved

Set Unordered List attributes in page_load

Posted on 2012-03-14
6
323 Views
Last Modified: 2012-03-14
I need to dynamically set the img src attributes of an unordered list in the page_load event.
How can I do this please in the sample list below?

        <div class="CarouSlide s3">
              <ul class="slider-holder">
                    <li id="no1c">
                          <img src="images/dashboard.jpg" width="50" height="50" />
                    </li>
                    <li id="no2c">
                          <img src="images/CO2a.jpg" width="50" height="50" />
                    </li>
                    <li id="no3c">
                          <img src="images/health.jpg" width="50" height="50" />
                    </li>
              </ul>
</div>
0
Comment
Question by:slimguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 37719635
Since you have an HTML element, instead of server control, you could 1) add an "id" and runat="server" element, and reference the control, or 2) use JavaScript in <body> onLoad handler.
0
 
LVL 35

Expert Comment

by:YZlat
ID: 37719933
why not use JQuery? Why page_load event?
0
 
LVL 35

Expert Comment

by:YZlat
ID: 37719964
$("img").attr({  
  src: "/images/dashboard.jpg", 
  title: "Dashboard", 
  alt: "Dashboard alt" 
}); 

Open in new window

0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 35

Expert Comment

by:YZlat
ID: 37719983
    $(".slider-holder li").("img").attr({  
  src: "/images/dashboard.jpg", 
  title: "Dashboard", 
  alt: "Dashboard alt" 
}); 

Open in new window


or

    $(".slider-holder #no1c").("img").attr({  
  src: "/images/dashboard.jpg", 
  title: "Dashboard", 
  alt: "Dashboard alt" 
}); 

Open in new window

0
 

Author Closing Comment

by:slimguy
ID: 37721919
Thanks, that was the hint I needed!
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37722548
I like the JQuery examples, too.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question