Changing image src before it's rendered?

Saturday, May 4, 2013

this jquery simple model add-in code works great to popup a fiXed image http://www.ericmmartin.com/projects/simplemodal-demos/    i'm trying to use inside an asp.net datalist solutoin that grabs images from a directory, but the problem is not ASP.NET or C# related.
 can't seem to make it DYNAMIC CHANGE WHICH IMAGE pops up (see this post for details).. If I use a set img src it works
 
 
 
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<script type="text/javascript">
    function ShowFullImg(url) {
        var img = $("#<%=Image1.ClientID %>");
        img.src = url;
        }
</script>
 

<div id='container'>
  
 
<div id="basic-modal-content">
<asp:Image ID="Image1" runat="server" />
</div>
 
 
 <div id='basic-modal'>
<ASP:DataList id="repeater1"  runat="server" repeatdirection="Horizontal" RepeatLayout="Table" Repeatcolumns="5">
<ItemTemplate>

<asp:ImageButton ID="ThumbnailImg" class="basic" ImageUrl='<%# Eval("n1") %>'  Height="100" Width="150" BorderStyle="Ridge"  OnClientClick='<%# Eval("n2","ShowFullImg(\"{0}\");return false;") %>'  runat="server" />                         
   
</ItemTemplate>
</asp:DataList>
    </div>
</div>
 
</asp:Content>
 
 
 
 
I suspect my problem is when I'm calling the javascript that updates the image.src i've likely already bound.
 

Agaom. my issue is NOT ASP.NET or C# related - at it is building the grid of thumbnails. I just want to be able to change the image that pops up  (Image1) with the correctly selected image.
 
 
No image pops up,just an empty popup box  box. My rendered code looks like this:
 
 
<script type="text/javascript">
    function ShowFullImg(url) {
        var img = $("#Maincontent_Image1");
        img.src = url;
        }
</script>
 
 
 
<div id='container'>
   
 
<div id="basic-modal-content">
<img id="Maincontent_Image1" src="" />
</div>
 
 
 <div id='basic-modal'>
 
<table id="Maincontent_repeater1" cellspacing="0" style="border-collapse:collapse;">
        <tr>
                <td>
 
 
<input type="image" name="ctl00$Maincontent$repeater1$ctl00$ThumbnailImg" id="Maincontent_repeater1_ThumbnailImg_0" class="basic" src="products/af/124-2424_IMG.JPG" onclick="ShowFullImg(&quot;products/af/124-2424_IMG.JPG&quot;);return false;" style="border-style:Ridge;height:100px;width:150px;" />
 
 
 
 
 
 
Many Thanks in advance for you help

--
You received this message because you are subscribed to the Google Groups "JavaScript Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javascript-information+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Copyright © 2010 Web Design | Free Blogger Templates by Splashy Templates | Layout by Atomic Website Templates

Vida de bombeiro Recipes Informatica Humor Jokes Mensagens Curiosity Saude Video Games Animals Diario das Mensagens Eletronica Rei Jesus News Noticias da TV Artesanato Esportes Noticias Atuais Games Pets Career Religion Recreation Business Education Autos Academics Style Television Programming Motosport Humor News The Games Home Downs World News Internet Design Entertaimment Celebrities 1001 Games Doctor Pets Net Downs World Enter Jesus Mensagensr Android Rub Letras Dialogue cosmetics Genexus lasofia thebushrajr wingshock tripedes gorduravegetal dainfamia dejavu-transpersonal jsbenfica republicadasbadanas ruiherbon iranianforaryans eaystcheyl fotosdanadir Só Humor Curiosity Gifs Medical Female American Health Madeira Designer PPS Divertidas Estate Travel Estate Writing Computer Matilde Ocultos Matilde futebolcomnoticias girassol lettheworldturn topdigitalnet Bem amado enjohnny produceideas foodasticos cronicasdoimaginario downloadsdegraca compactandoletras newcuriosidades blogdoarmario arrozinhoii