You are currently browsing the category archive for the ‘javascript’ category.

I came across an interesting problem the other day. I was developing a way to have error dialog for our web application regardless of the web browser. I did not want to use the JavaScript alert message box. I could not use the IE Modal dialog. So I decided to display the error message in a DIV tag that would be centered on the screen and only made visible when there was an error. Then I thought, wouldn’t it be cool to be able to move the error dialog around the screen, in case it was covering up the form element that had a problem. I found dom-drag.js to be quite cool andListBox Example very helpful.

To make the DIV tag overlay the existing page, I needed to set the Z-index of the DIV at a higher level then anything else on the page. I soon found that no matter how hard you tried, all DropDownList boxes and List boxes would show through the error dialog.

After some research, I soon found that this is an issue with Internet Explorer and wasn’t much I could do about it. It is because DropDownList boxes and List boxes are considered a windowed component in the browser and regardless the z-index you assign these components or the DIV that contains them, they will always float to the top. This issue is resolved in IE7, but the idea of making all customers upgrade to IE7 was not acceptable.

Read the rest of this entry »

More issues with Atlas and your own client javascript.

Today I stumbled accross another isse of my own JavaScript causing errors with Atlas. Typically you place all your JavaScript in the HEAD of the document. So.. today I added the following function to my JavaScript in the HEAD of the page.

javascript_form_submit

Atlas - Unknown ErrorAfter adding this code, any click on the page that used an Atlas Update Panel, caused the discreet Unknown Error dialog box. After many attempts to discove what the problem may be, I moved the entire function to script tags with-in the BODY of the page. All worked fine, with no Atlas “Unknown Error”.

I decided to test another sceniario, and put all my JavaScript in an external file (I usually wait till I am finished with the page for this step) and included it from with-in the HEAD of the page. Again I tested the page and all worked fine with no Atlas “Unknown Error”.

I thought this error may have something to do with the partial rendering that Atlas is taking care of, but after my second test, I an not so sure any more. Either way, I believe it may be a better practice to put all JavaScript in an external .js file and include it in the HEAD of your page.

Hey, just got a tip from a friend, Steve. This tip will help prevent the issue of double quotes or no double quotes around javascript for the language attribute.

In Visual Studio 2005, go to Tools>Options> Text Editor > HTML > Format > Check both:

  • “Insert attribute value quotes when typing”
  • “Insert attribute value quotes for formatting”

VisualStudioToolsOptions
This will ensure all attribute values, such as the javascript value of the language attribute is always surrounded with quotes.

Thank you Steve.

I found another issue using Atlas the other day. I was using Atlas UpdatePanel around a TreeView and had some java-script functions on the page elsewhere. All was going fine Tuesday evening, then Wednesday morning, I started getting a what appeared to be a java-script error message.

Atlas - Unknown Error

When debugging, I was able to confirm that Atlas was working, I could step through my server code and populate the tree, but when execution was back at the browser, I would get this error pop-up “Unknown Error”.

I had made very little changes that morning, but due to closing the file earlier, I was unable to use the Undo function. After much time and testing, I remembered that in the HEAD of the HTML document, I had added another java-script function and noticed that the <script> tag did not have the language set, so I had set language=javascript. In Visual Studio 2005, the context sensitive help is great, and after typing language= it prompts with a choice of languages, and when you choose the language it adds it to your code with out quotes.

Now most of the time I have found that it doesn’t matter if you have quotes or not around your values. But this time it made a big difference. I added the double quotes around javascript and tested the page again, and this time there was no error and everything worked fine.

Intrigued by this finding, I did some more testing and found that if I put the SCRIPT tags with java-script functions just below the BODY tag, it did not matter if I used language=javascript or language=”javascript”, both ways worked just fine with Atlas.

So, in the HEAD of the HTML document, I needed to use language=”javascript”, but in the BODY of the HTML, double quotes didn’t seem to matter.

Also, see my post in this thread:
http://forums.asp.net/thread/1363655.aspx