Startup script problem

B

bill yeager

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

bruce barker

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)


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

Anders Norås [MCAD]

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top