RegisterClientScriptBlock
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngclient' list.


Tim Royal
-- Moved from [aspngstart] to [aspngclient] by Tony Stark <Click here to reveal e-mail address> --

Howdy howdy.

I have a question. asp.net has the functions registerclientscriptblock, etc.
for sending down script to be executed on the client side. I do notice that
these are attached to the <FORM> element, not in the <HEAD> tag.

I've read up and I know they have a reason (assigning it to a server
control), but the problem is that Netscape tends to be finicky about certain
client side script if it's not in the head tag. Not universally, but
intermittently problems will arise, and the solution of our web devs has
been to place all script in the head tag (for uniformity as well).

Does anybody know of a way to register client scripts in the head tag? I'm
thinking if not that I coudl write a class my pages derive from that stores
client script and then replaces some literal control in the head tag on the
pages with the client script i store up during the render.

thanks for any insight.

tim

Reply to this message...
 
    
Tim Royal

Howdy howdy.

I have a question. asp.net has the functions registerclientscriptblock, etc.
for sending down script to be executed on the client side. I do notice that
these are attached to the <FORM> element, not in the <HEAD> tag.

I've read up and I know they have a reason (assigning it to a server
control), but the problem is that Netscape tends to be finicky about certain
client side script if it's not in the head tag. Not universally, but
intermittently problems will arise, and the solution of our web devs has
been to place all script in the head tag (for uniformity as well).

Does anybody know of a way to register client scripts in the head tag? I'm
thinking if not that I coudl write a class my pages derive from that stores
client script and then replaces some literal control in the head tag on the
pages with the client script i store up during the render.

thanks for any insight.

tim royal

Reply to this message...
 
    
Ollie Cornes

Hi Tim,

The reason for this is that an ASP.NET is fairly likely to have a
server-side form tag, but it's fairly unlikely to have a server-side head
tag. In fact Visual Studio .NET is very enthusiastic about stripping the
runat=server attribute from the head tag if you add it. The RegisterXXX
methods place their script in and around the <form> tag so, for example the
startup script goes just after the </form>. The reason for this is that the
script needs to be added to the control tree, and to do that it needs to be
bolted in somewhere. But where? What can we pretty much guarantee will be
present on all pages? Ah, the <form> tags!

There's nothing magical about the RegisterXXX methods, they're just an easy
way to get script into the page. I don't believe there's any in-built
support in the Framework for adding script to the <head> so your
literal-based solution looks like a good one.

Ollie

PS I just read your post again and I'm repeating things you said. Sorry!

--
http://www.richtextbox.com/
The no. 1 content editor for ASP.NET

----- Original Message -----
From: "Tim Royal" <Click here to reveal e-mail address>
To: "aspngclient" <Click here to reveal e-mail address>
Sent: Thursday, August 01, 2002 9:47 PM
Subject: [aspngclient] RegisterClientScriptBlock

[Original message clipped]

Reply to this message...
 
    
Tim Royal
Howdy howdy. Thanks for responding. I guess I can see why there isn't a way
to registerclientscriptblockinheadtag() :) It's funny, because my pages
almost never
have a form tag (except for the ones with actual form elements), but they
always
have a head tag. I'm backwards! :)

It wouldn't be a big deal if it wasnt' for netscape's flakiness and our
current
client side scripting blocks that generate menus. That, and I've always been
one
of those weird people that likes to have script tags inside the head instead
of in
the body.

I'll go ahead and build in the method below. I really appreciate your
response. At least
I understand why.

Thanks!

Tim

->-----Original Message-----
->From: Ollie Cornes [mailto:Click here to reveal e-mail address]
->Sent: Friday, August 02, 2002 2:02 AM
->To: aspngclient
->Subject: [aspngclient] Re: RegisterClientScriptBlock
->
->
->
->Hi Tim,
->
->The reason for this is that an ASP.NET is fairly likely to have a
->server-side form tag, but it's fairly unlikely to have a
->server-side head
->tag. In fact Visual Studio .NET is very enthusiastic about
->stripping the
->runat=server attribute from the head tag if you add it. The
->RegisterXXX
->methods place their script in and around the <form> tag so,
->for example the
->startup script goes just after the </form>. The reason for
->this is that the
->script needs to be added to the control tree, and to do that
->it needs to be
->bolted in somewhere. But where? What can we pretty much
->guarantee will be
->present on all pages? Ah, the <form> tags!
->
->There's nothing magical about the RegisterXXX methods,
->they're just an easy
->way to get script into the page. I don't believe there's any in-built
->support in the Framework for adding script to the <head> so your
->literal-based solution looks like a good one.
->
->Ollie
->
->PS I just read your post again and I'm repeating things you
->said. Sorry!
->
->--
->http://www.richtextbox.com/
->The no. 1 content editor for ASP.NET
->
->
->----- Original Message -----
->From: "Tim Royal" <Click here to reveal e-mail address>
->To: "aspngclient" <Click here to reveal e-mail address>
->Sent: Thursday, August 01, 2002 9:47 PM
->Subject: [aspngclient] RegisterClientScriptBlock
->
->
->>
->> Howdy howdy.
->>
->> I have a question. asp.net has the functions
->registerclientscriptblock,
->etc.
->> for sending down script to be executed on the client side.
->I do notice
->that
->> these are attached to the <FORM> element, not in the <HEAD> tag.
->>
->> I've read up and I know they have a reason (assigning it to a server
->> control), but the problem is that Netscape tends to be finicky about
->certain
->> client side script if it's not in the head tag. Not universally, but
->> intermittently problems will arise, and the solution of our
->web devs has
->> been to place all script in the head tag (for uniformity as well).
->>
->> Does anybody know of a way to register client scripts in
->the head tag? I'm
->> thinking if not that I coudl write a class my pages derive from that
->stores
->> client script and then replaces some literal control in the
->head tag on
->the
->> pages with the client script i store up during the render.
->>
->> thanks for any insight.
->>
->> tim royal
->>
->>
->> | [aspngclient] member Click here to reveal e-mail address = YOUR ID
->> | http://www.aspfriends.com/aspfriends/aspngclient.asp = JOIN/QUIT
->>
->
->
->| [aspngclient] member Click here to reveal e-mail address = YOUR ID
->| http://www.aspfriends.com/aspfriends/aspngclient.asp = JOIN/QUIT
->

Reply to this message...
 
    
Andy Smith
when building asp.net applications, things go much smoother if you build =
your pages like this:

<html><head>
<!-- your head stuff
</head>
<body><form runat=3D"server">

<!-- your page -->

</form></body></html>

this makes sure that your script libraries are declared before any =
content.

__
Andy Smith
Keyboard Jockey #3a7-2.78.1

[Original message clipped]

Reply to this message...
 
 




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com