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';
}
else
{
document.all[commId].style.display = 'none';
document.all[imageId].src = '../Images/collapse.gif';
}
}
</SCRIPT>
Best Regards,
Vivek.
__________________
Best Regards,
Vivek.
|