Ask a questionAsk a question
 

AnswerIMG onclick error

  • Tuesday, May 19, 2009 11:22 AMCarmenDev Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Hi all,

    I have a little problem with an IMG on my HTML code. I assign an attribute onclick to a javascript method, it fails me with a javascript error notifying me that an object is expected, but I cannot resolve what exactly I'm doing wrong.

    This is my code:

    [vb Code]
    Me.btnCerrar.Attributes.Add("onclick", "javascript:qmCerrar();")
    
    [HTML Code]
    <table id="Table1" runat="server" border="0" cellpadding="0" cellspacing="0" class="cabeceraTabla" style="z-index: 106; left: 0px; width: 368px; position: absolute; top: 0px; height: 6px">
    <tr>
          <td style="height: 19px; width: 372px;">
                <asp:Label ID="labTituloLayFoto" runat="server" CssClass="etiquetaFiltro" Text="Añadir Fotografía" Style="z-index: 130; left: 5px; position: absolute; top: 3px"  Width="109px"></asp:Label>
          </td>
          <td align="right" style="width: 0px; height: 19px; text-align: right;">
               <img id="btnCerrar" runat="server"  class="cursor" src="../Imagenes/imgBotonCerrar.gif" style="height:14px;width:15px;z-index: 102; left: 312px; position: absolute; top: 2px"/>&nbsp;
         </td> 
    </tr>
    </table>

    Programmer

Answers

  • Thursday, May 21, 2009 6:34 AMCarmenDev Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Rohit,

    I forgot to include the function in this thread but it exists in my original code as you write (only with an alert).  

    I've resolved the problem anyway. Just calling the same method that opens the iFrame including an if...else condition to close it.

    I think we could close this thread.

    Thanks a lot for your help (^^).

    My Best Regards,
    CarmenDev
    Programmer

All Replies

  • Thursday, May 21, 2009 2:34 AMRohit S Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    I tried your code, I do not get any error. The only difference that I added (which is not shown in your code sample):

    <script language=javascript>
        function qmCerrar()
        {
        alert('hello');
        }
    </script>

    It seems you haven't written qmCerrar() function.
  • Thursday, May 21, 2009 6:34 AMCarmenDev Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Rohit,

    I forgot to include the function in this thread but it exists in my original code as you write (only with an alert).  

    I've resolved the problem anyway. Just calling the same method that opens the iFrame including an if...else condition to close it.

    I think we could close this thread.

    Thanks a lot for your help (^^).

    My Best Regards,
    CarmenDev
    Programmer
  • Thursday, June 04, 2009 1:32 PMsaravmani Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    hi,
    in attributes u can ad ____ follows


    Me.btnCerrar.Attributes.Add("onclick", "qmCerrar()")

    dont use "javascript:".

  • Thursday, June 04, 2009 1:54 PMCarmenDev Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi saravmani,

    I also tried this too, but without results.

    Thanks for your help (^^).

    Best Regards,
    CarmenDev

    Programmer
  • Wednesday, September 23, 2009 12:11 PMsaravmani Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    hi sorry for delay reply....i think u may got ans....if not try this.....


    in aspx itself u can use the event.....


    <img id="btnCerrar" runat="server" onclic="FunctionName()"  class="cursor" src="../Imagenes/imgBotonCerrar.gif"...... />