View Single Post
  #1 (permalink)  
Old June 14th, 2006, 02:00 AM
vivek_inos vivek_inos is offline
Authorized User
Join Date: Nov 2005
Location: mumbai, maharashtra, India.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default Javscript works well in aspx page but fails...

Hello Everyone,

I am using Javascript which is called on click of image from c# code...
this script works fine in aspx page but i use this same code in ascx.cs custom control this script fails to detect an object such as div and image...this is the script....when i com[ared the view source of both aspx page and custom control. The Script in page was in head section and postback script was found. Where in Custom Control view source the javascript was in body section and no post back script was found.... Any Help or Idea will be appreciated

<SCRIPT language="javascript">

 function Toggle( commId, imageId )

    var div = this.document.getElementById(commId);
    var GetImg = this.document.getElementById(imageId);
     alert (commId+" and "+imageId)
displays corresponding value
    alert (div+" and "+GetImg)
fails to display detects object and displays null
    if (document.all[commId].style.display == 'none')
     document.all[commId].style.display = 'block';
     document.all[imageId].src = '../Images/expand.gif';
     document.all[commId].style.display = 'none';
     document.all[imageId].src = '../Images/collapse.gif';

Best Regards,
Best Regards,