By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,246 Members | 1,451 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,246 IT Pros & Developers. It's quick & easy.

Startup script problem

P: n/a
I'm registering a startup script in my "page load" event.
Everything works fine when I run it locally, but when it's
deployed to the webserver, it doesn't execute the
javascript which is inside a ".js" file (on the root
directory of the website).

Here is the HTML where I have the javascript function to
execute:
<code>
<TD style="HEIGHT: 23px">

<input name="txtEnding" type="text" value="100"
id="txtEnding" tabindex="24"
onChange="CalculateTotalMileage();"
style="width:96px;" /></TD>
</code>

Here is the code in my code behind page:
<code>
Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load

RegisterScripts()
..
..
..

Private Sub RegisterScripts()

txtMileageBeginning.Attributes.Add
("onChange", "CalculateTotalMileage();")
txtEnding.Attributes.Add
("onChange", "CalculateTotalMileage();")
ddlDispatchInfo.Attributes.Add
("onChange", "EnableDispatchInfoOther();")

If (Not IsClientScriptBlockRegistered
("PageStartupJScript")) Then
RegisterClientScriptBlock
("PageStartupJScript", "<script language=""javascript""
src=""/EMSAssist/ClientFunctions.js""></script>")
End If

End Sub
</code>

Why isn't the web application recognizing the javascript
functions when it's deployed to the webserver?
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
the path to the ClientFunctions.js is probably wrong.

type in

http://servername/vdirname/EMSAssist/ClientFunctions.js

and see if the file downloads

-- bruce (sqlwork.com)
"bill yeager" <an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
| I'm registering a startup script in my "page load" event.
| Everything works fine when I run it locally, but when it's
| deployed to the webserver, it doesn't execute the
| javascript which is inside a ".js" file (on the root
| directory of the website).
|
| Here is the HTML where I have the javascript function to
| execute:
| <code>
| <TD style="HEIGHT: 23px">
|
| <input name="txtEnding" type="text" value="100"
| id="txtEnding" tabindex="24"
| onChange="CalculateTotalMileage();"
| style="width:96px;" /></TD>
| </code>
|
| Here is the code in my code behind page:
| <code>
| Private Sub Page_Load(ByVal sender As System.Object, ByVal
| e As System.EventArgs) Handles MyBase.Load
|
| RegisterScripts()
| .
| .
| .
|
| Private Sub RegisterScripts()
|
| txtMileageBeginning.Attributes.Add
| ("onChange", "CalculateTotalMileage();")
| txtEnding.Attributes.Add
| ("onChange", "CalculateTotalMileage();")
| ddlDispatchInfo.Attributes.Add
| ("onChange", "EnableDispatchInfoOther();")
|
| If (Not IsClientScriptBlockRegistered
| ("PageStartupJScript")) Then
| RegisterClientScriptBlock
| ("PageStartupJScript", "<script language=""javascript""
| src=""/EMSAssist/ClientFunctions.js""></script>")
| End If
|
| End Sub
| </code>
|
| Why isn't the web application recognizing the javascript
| functions when it's deployed to the webserver?
Nov 19 '05 #2

P: n/a
> I'm registering a startup script in my "page load" event.
Everything works fine when I run it locally, but when it's
deployed to the webserver, it doesn't execute the
javascript which is inside a ".js" file (on the root
directory of the website).
...
If (Not IsClientScriptBlockRegistered
("PageStartupJScript")) Then
RegisterClientScriptBlock
("PageStartupJScript", "<script language=""javascript""
src=""/EMSAssist/ClientFunctions.js""></script>")
End If
...
Why isn't the web application recognizing the javascript
functions when it's deployed to the webserver?


Have you got the same directory structure on your local computer and on the
web server? The url "/EMSAssist/ClientFunctions.js" referes to a file named
ClientFunctions.js located in the EMSAssist folder on the root of the web
server.
To ensure that the java script file actually is loaded by the browser, add
an alert("Loaded!"); statement to the file.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.