Solved

How to replace src content in image control in jquery?

Posted on 2014-09-24
3
150 Views
Last Modified: 2014-09-27
Hi,
I have this jquery code below that works fine with the label web control. What it basically does is to find the webcontrol with the specific id and eval the data from xml table.

Works fine
=================
$(".filename", table).html(customer.find("filename").text());

<asp:Label ID="lblFilename" class="filename" runat="server" Text='<%# Eval("filename")%>'></asp:Label>



Now what if i want to use the same application on a image control? The below doesn't work

Not working
==============
$(".imgPhoto", table).html(customer.find("filename").text());

<img class="imgPhoto" src='<%# Eval("filename")%>' />

Any help is greatly appreciated.
0
Comment
Question by:tangteng78
3 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 250 total points
ID: 40342044
If you want to change the img src

$(".imgPhoto", table).attr("src","newsource.jpg")
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
ID: 40342124
try this :

jQuery(function($) { // be sure to wait complete page loading of the page, similar to window.onload or $(document).ready(function() {
     var filename = $("<%= lblFilename.ClientID %>").text();
     $("table .imgPhoto").attr("src", filename);
});

Open in new window

0
 

Author Closing Comment

by:tangteng78
ID: 40347469
Bulls eye
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

by Julian Matz As of jQuery (http://jquery.com/) 1.4 the .live() method (http://api.jquery.com/live/) supports custom events as well as some standard JavaScript events that it previously didn't support. Among these is the submit event. Unlike …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now