Link to home
Start Free TrialLog in
Avatar of gogetsome
gogetsomeFlag for United States of America

asked on

Javascript/ASP.net Usercontrol Error

Hello, I have some webuser controls that I load onto an aspx page at runtime. Within these controls I allow the user to show and hide a div using a javascript function on the parent page and a little css. I have a straight html page with an example below which does not produce the "done with errors javascript error and the bottom of the page". In aspx pages it does.

In my asp.net parent page I have the javascript function. Within all the controls I have the toggle buttons and the div.

It works fine but I would like to get it working without the error...
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
   <style type="text/css">
div#commentForm{  margin: 0px 20px 0px 20px;  display: none;color:black}
</style>
 
    <script language="javascript" type="text/javascript">
 
function toggleLayer( whichLayer )
{  
var elem, vis;  
if( document.getElementById ) // this is the way the standards work    
elem = document.getElementById( whichLayer );  
else if( document.all ) // this is the way old msie versions work      
elem = document.all[whichLayer];  else if( document.layers ) // this is the way nn4 works    
elem = document.layers[whichLayer];  
vis = elem.style;  
// if the style.display value is blank we try to figure it out here  
if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)    
vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  
vis.display = (vis.display==''||vis.display=='block')?'none':'block';}
    
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <a href="javascript:toggleLayer('commentForm');" title="Show Div">Show Div</a>
   
    <div id="commentForm">dfasdfasdfasdfasdfasdf<br /><br />
     <input type="reset" name="reset" value="Hide Div"onclick="javascript:toggleLayer('commentForm');" /></div>
    </div>
    </form>
</body>
</html>

Open in new window

Avatar of sunithnair
sunithnair

Can you click on the little exclamation mark next to which it shows done with errors and see what is the exact error. Please paste that here
ASKER CERTIFIED SOLUTION
Avatar of sunithnair
sunithnair

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gogetsome

ASKER

Thank you! It was some other script and not this one that was causing the error.