Saturday, March 24, 2012

UpdatePanel and custom javascript.js files

Hi,

We are piloting Atlas for our web project and for the most part it works quite well. We are mainly using UpdatePanels to return validation details which need to be processed on the server based upon business rules.

The issue we have is to do with Atlas and our own custom javascript .js files which we include on some pages. When we include our .js files using the follwing syntax:

<script language="javascript" src=../js/hints.js></script>

We get a message box appear stating 'unknown error' under IE and no response under FireFox. If we paste the actual source code from the hints.js file into the aspx page like:

<script language="javascript" src=../js/hints.js>
function(page, name)
{
window.open(page, name);
return
}
</script>

Everything works fine. The partial postback works returning any validation error messages. This is in both IE and FireFox.

This poses a problem for us as we have a standard template of .js files which we include on every page via an include.htm file.

Since Atlas uses javascript, do we have to include our own custom scripts a special way, or is this a bug with Atlas at the moment?Hi,

a couple of suggestions:

1. you should add the type attribute for a script element: <script type="text/javascript" /> Atlas does some of its stuff by searching for the type attribute, so you may experience problems if you omit it.

2. enclose an attribute's value in double quotes: src="http://pics.10026.com/?src=../js/hings.js"

3. Do not put the script element in the <head /> section of the page when using Atlas.

4. Use the Page.ClientScript API if you are going to inject client script blocks in the page.

5. If you want to keep everything in one place, add a reference to your custom script in the Scripts section of the ScriptManager control.

No comments:

Post a Comment