Solved

How to replace src content in image control in jquery?

Posted on 2014-09-24
3
160 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses

623 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