473,396 Members | 1,666 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,396 software developers and data experts.

Page.ClientScript question about Javascript

Hi,
Newbie question: Why use Page.ClientScript.RegisterClientScript*
when we can just make a .js file and include a reference to it in the page?
(i.e. <script src="myscript.js" type="text/javascript"></script>)

Is it because RegisterClientScript* enables us to reference ASP.NET
objects within the .js?

Thx,
Hank
Jan 22 '07 #1
3 3004
"First Last" <es**********@yahoo.comwrote in message
news:bs******************************@speakeasy.ne t...
Is it because RegisterClientScript* enables us to reference ASP.NET
objects within the .js?
No - it's because it allows dynamic JavaScript.
Jan 22 '07 #2
The purpose would be to add the reference at runtime instead of design time.
If you know the details of the JavaScript file at design time it would be
best to declare it then, otherwise you'd be pretty much forced to use
RegisterClientScript.

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"First Last" <es**********@yahoo.comwrote in message
news:bs******************************@speakeasy.ne t...
Hi,
Newbie question: Why use Page.ClientScript.RegisterClientScript*
when we can just make a .js file and include a reference to it in the
page? (i.e. <script src="myscript.js" type="text/javascript"></script>)

Is it because RegisterClientScript* enables us to reference ASP.NET
objects within the .js?

Thx,
Hank
Jan 22 '07 #3
it mainly for controls that spew javascript. they can not edit the page
text.

-- bruce (sqlwork.com)

First Last wrote:
Hi,
Newbie question: Why use Page.ClientScript.RegisterClientScript*
when we can just make a .js file and include a reference to it in the page?
(i.e. <script src="myscript.js" type="text/javascript"></script>)

Is it because RegisterClientScript* enables us to reference ASP.NET
objects within the .js?

Thx,
Hank

Jan 22 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: fxs | last post by:
Hello, I've got the following elements on my page: A Body tag that looks like this: <body onload="setTabs()"> A Javascript script in the <head> that has: var foo; function setTabs() {...
9
by: sck10 | last post by:
Hello, I have a page with an ImageButton that is used to redirect to another page. When the page first opens, everything looks as expected. However, when I click on the image, the new page...
4
by: Mori | last post by:
I am using masterPage and I need to populate a textbox that is in a content control with data from popup page that is not part of the master page. This code works if no masterpage is involved. ...
4
by: Anna S | last post by:
Hi all, I have an aspx page that opens with some parameter (mypage.aspx?idclient=1). Next, I have a dropdown list on this page that lets select the new value of parameter idclient. Than I just...
0
by: theOr1ent | last post by:
Hi. I am having a problem with a JavaScript activation when leaving a TextBox control. My default.aspx page has the following control and event; <asp:TextBox ID="txtBirthDate"...
2
by: =?Utf-8?B?Qw==?= | last post by:
Hi, I have a 3 dimenionsal array which I populate in my C# code. I then want to make this available to my Javascript so I do below. Page.ClientScript.RegisterArrayDeclaration("myArray",...
0
by: e_spork | last post by:
I am using Page.ClientScript.RegisterStartupScript to throw up a Javascript alert box. When I click OK on the alert box, all the controls on my page disappear and I don't understand why. I can...
2
by: Jonathan Wood | last post by:
I've created some javascript and added it to my page (from a user control) using Page.ClientScript.RegisterClientScriptBlock. The javascript hides and shows certain elements in response to radio...
6
by: Danielle | last post by:
Greetings all - I am working on a vb .NET asp web application. I have a button that opens a new page when clicked. It works fine; the problem is when the user refreshes the original page, the...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.