.NET Framework Bookmark and Share   
 index > JScript for the .NET Framework > IMG onclick error
 

IMG onclick error

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
CarmenDev
Hi Rohit,

I forgot toinclude 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
CarmenDev
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.
Rohit S
Hi Rohit,

I forgot toinclude 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
CarmenDev
hi,
in attributes u can ad ____ follows


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

dont use "javascript:".

saravmani
Hi saravmani,

I also tried this too, but without results.

Thanks for your help (^^).

Best Regards,
CarmenDev

Programmer
CarmenDev

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"...... />

saravmani

You can use google to search for other answers

Custom Search

More Threads

• How to access Element from page loaded inside Iframe, where My page is containing that iframe Tag...Please Help
• WebControls TreeView looks different in IE than in FireFox
• ECMAScript(Javascript) for XML(E4X) in IE7 BETA 3
• Calling into your BHO from a client script:
• Support for E4X anytime soon?
• Group policy management GPMGMT
• Quasi - Urgent question on Client-side Jscript and Webservices.
• How to get the Excel built-in dialog that allows to drag cells and get their addresses?
• Multi-threading in javascript
• How to call external function defined in microsoft jscript