Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to replace src content in image control in jquery?

Posted on 2014-09-24
3
Medium Priority
?
165 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
[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 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 1000 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 1000 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

705 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