• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

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

0
gogetsome
Asked:
gogetsome
  • 2
1 Solution
 
sunithnairCommented:
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
0
 
sunithnairCommented:
Alternately you can enable script debugging from IE->internetoptions->advanced tab->uncheck disable script debugging apply and reload the page. When is asks for debud press yes and see which line creates the problem and let us know
0
 
gogetsomeAuthor Commented:
Thank you! It was some other script and not this one that was causing the error.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now