Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript Error in .Net

Status
Not open for further replies.

HighTower328

Programmer
Aug 22, 2006
6
US
I have an ASP.Net 2 application that I'm building, and need to implement an image gallery. I found a script on another forum and tried to implement it in my app. My problem is when I test the page, I keep getting an error saying "imgprop" undefined.

Can someone take a look at my code, and see what the problem is?

Code:
<%@ Page Language="VB"  MasterPageFile ="~/Home_english.master" %>


<asp:Content ID="Content1"  ContentPlaceHolderID = "MainContent" runat = "server">
<script language="JavaScript">
<!--

function changeimg(imgpath)
{
    imgprop.src = imgpath;
}
// -->
</script>
<span class="pagehdr">
        Mile Maker Photo Gallery
</span>
<table width="100%" border="0" cellspacing="0" cellpadding="5" align="left" height="100%">
<tr valign="top">
  <td width="20" bordercolor="#FDB945" bgcolor="#FDB945" valign="top"> 
      
<!-- var needs to be 'plants' 'parts' or 'both' -->
 </td>
<td> 
      <div align="center"> 
        <table width="100%" border="0" cellspacing="0" cellpadding="5" align="left">
          <tr align="left" valign="top" bordercolor="#FDB945"> 
            <td width="100%" bordercolor="#FDB945" bgcolor="#FFFFFF" valign="middle" style="height: 45px"> 
              <div align="center"><a href="MileMaker.asp"><img src="/dev2006/images/mm_logo.jpg" width="107" height="109" border="0"></a></div>
            </td>

            <td width="100%" align="center" bordercolor="#FDB945" style="height: 45px">&nbsp;
            <tr align="left" bordercolor="#fdb945" valign="top">
                <td bgcolor="#ffffff" bordercolor="#fdb945" valign="middle" width="100%" style="height: 61px">
  
<!-- Default image for gallery -->
                    <img src="/images/mmbig_01.jpg" name="imgprop" vspace="2" id="imgprop">
                
                </td>
                <td align="center" bordercolor="#fdb945" width="100%" style="height: 61px">
                </td>
            </tr>
          
          <tr align="left" valign="top" bordercolor="#FDB945"> 
            <td height="300" width="100%" bordercolor="#FDB945" bgcolor="#FFFFFF"> 
                
              <p align="center"><font face="Arial, Helvetica, sans-serif" size="2" color="#000000">Click 
                on the images to enlarge.</font></p>
              <p align="center">
              <font size="2" face="Arial, Helvetica, sans-serif"><b><font size="1">1</font></b></font>
 <!-- Gallery images and links -->   
              <a href='javascript:changeimg("images/mmbig_01.jpg")'><img src="/images/back_100.jpg" width="72" height="90" border="0" align="texttop"></a>
              <a href='javascript:changeimg("images/mmbig_01-click.jpg")'><img src="/images/back_102.jpg" width="72" height="90" border="0" align="texttop"></a>
              <a href='javascript:changeimg("images/mmbig_01-down.jpg")'><img src="/images/back_58.jpg" width="72" height="90" border="0" align="texttop"></a>
              <a href='javascript:changeimg("images/mmbig_01-over.jpg")'><img src="/images/back_79.jpg" width="72" height="90" border="0" align="texttop"></a>
              <a href='javascript:changeimg("images/mm2small.jpg")'><img src="/images/mm2small.jpg" width="72" height="90" border="0" align="texttop"></a>
              <a href='javascript:changeimg("images/mm3.jpg")'><img src="/images/mm3small.jpg" width="72" height="90" border="0" align="texttop"></a>
              <a href='javascript:changeimg("images/mm4.jpg")'><img src="/images/mm4small.jpg" width="72" height="90" border="0" align="texttop"></a>
              <a href='javascript:changeimg("images/mm5.jpg")'><img src="/images/mm5small.jpg" width="72" height="90" border="0" align="texttop"></a>
              <a href='javascript:changeimg("images/mm9.jpg")'><img src="/images/mm9small.jpg" width="72" height="90" border="0" align="texttop"></a>
       
                          
            </td>
        </tr>
        </table>
        </div>
</td>
</tr>
</table>
</asp:Content>
 
It's a javascript issue so you should really take this to the javascript forum.

As a quick test though, try using:
Code:
document.getElementById('imgprop').src = imgpath;


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ca8msm, thanks for the help. Problem solved.

I realize it was a javascript issue, but since it dealt with both ASP.net and JavaScript, I had trouble deciding which forum to post in first.


Thank Again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top