Javascript/ Usercontrol Error

Posted on 2009-02-12
Last Modified: 2012-05-06
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 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="">

<head runat="server">

    <title>Untitled Page</title>

   <style type="text/css">

div#commentForm{  margin: 0px 20px 0px 20px;  display: none;color:black}



    <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 =;  

// if the style.display value is blank we try to figure it out here  


vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';  

vis.display = (vis.display==''||vis.display=='block')?'none':'block';}





    <form id="form1" runat="server">


    <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>





Open in new window

Question by:gogetsome
    LVL 16

    Expert Comment

    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
    LVL 16

    Accepted Solution

    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

    Author Closing Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now