473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 4255
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Alan Silver | last post by:
Hello, In classic ASP, I used to use two include files on each page, one before and one after the main content, to provide a consistent layout across a web site. That way I could just change the...
6
by: Naveen K Kohli | last post by:
I have couple of javascript files that need to be referenced for each content page. So I am trying to put them on Master page. The problem is that content pages are not on one level of the site. I...
8
by: otto | last post by:
Hi, all: I have a problem with the inclusion of .js files in mu .aspx pages when using Master Pages. I try to explain it. If I make a web project without master pages I simply put in the head...
4
by: Greg | last post by:
I'm guessing the problem I'm having has something to do with Master Pages or DetailsView because the exact same code works fine on a page without a Master Page and DetailsView controls. The...
9
by: Andy | last post by:
Hey all, I'm building out my first project using asp.net v2.0 master pages. It seems that when you use master pages and try to reference document.body.scrollTop it allways = zero/0. The same code...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
5
by: Joey | last post by:
I have the following in the head section of the ASPX page for my master page: <script language="javascript" type="text/javascript" src="MyCodeFile.js"></script> This includes my external...
0
by: dixonjm | last post by:
Hi, I have a master page & various pages that will use this master page. Each content page will have a CSS & JS file which will be named the same as the content page. When I try to load the CSS...
8
by: Cirene | last post by:
I have 1 master page in the root of my website that I would like to share with all pages, even those in my /admin and /client directories. But when pages in the subdir's are viewed the img, css,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.