470,573 Members | 1,668 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,573 developers. It's quick & easy.

Master Pages using JavaScript.js file

Hi,

I want to incorporate a JavaScript routine (found on the internet) in my
page that will restore the scrollbar position of a div tag on postback. I am
using master pages which complicates things and also want to reference the
script via a ".js" file. Below is the code I have come-up with but it
doesn't work (I get a blank screen). The script is located in the project
folder in the JavaScript folder. Any ideas?

Thanks,
Jeff
Page.RegisterClientScriptBlock("MyScript", "<script
language=javascript src='JavaScript/sscroller.js'>");
Dec 6 '07 #1
1 4095
Jeff,

Instead of using the RegisterClientScriptBlock (which is tagged as
obsolete) why not just use the RegisterClientScriptInclude method on the
ClientScriptManager class? You don't need to write the script, you just
would have to include the url of the script to include.

Also, I notice you are using a relative URL. If this is a master page,
and it is going to be used for pages across different directories, then the
URL is constantly going to change. You might want to make the URL relative
to the root, using "/JavaScript/sscroller.js" (note the initial slash).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"jeff3048" <je******@discussions.microsoft.comwrote in message
news:52**********************************@microsof t.com...
Hi,

I want to incorporate a JavaScript routine (found on the internet) in my
page that will restore the scrollbar position of a div tag on postback. I
am
using master pages which complicates things and also want to reference the
script via a ".js" file. Below is the code I have come-up with but it
doesn't work (I get a blank screen). The script is located in the project
folder in the JavaScript folder. Any ideas?

Thanks,
Jeff
Page.RegisterClientScriptBlock("MyScript", "<script
language=javascript src='JavaScript/sscroller.js'>");

Dec 7 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Naveen K Kohli | last post: by
8 posts views Thread by otto | last post: by
9 posts views Thread by Andy | last post: by
17 posts views Thread by Rob R. Ainscough | last post: by
8 posts views Thread by Cirene | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.