Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Set Unordered List attributes in page_load

Posted on 2012-03-14
6
Medium Priority
?
347 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
  • 3
  • 2
6 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1000 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
Independent Software Vendors: 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!

 
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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Screencast - Getting to Know the Pipeline
Suggested Courses

916 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