473,503 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RegisterStartupScript not creating a <SCRIPT> block

When I do this in my page...
ClientScript.RegisterStartupScript(this.GetType(), "SomeScript",
"alert(\"Hi there\");");

it doesn't work AND when I view source, the alert() line is dumped into the
HTML but with no <SCRIPT> block around it. Why would this be happening?

Alex

Apr 30 '06 #1
4 2204
"Alex Maghen" <Al********@newsgroup.nospam> wrote in message
news:F9**********************************@microsof t.com...
When I do this in my page...
ClientScript.RegisterStartupScript(this.GetType(), "SomeScript",
"alert(\"Hi there\");");

it doesn't work AND when I view source, the alert() line is dumped into
the
HTML but with no <SCRIPT> block around it. Why would this be happening?


It doesn't add the script blocks, it simply adds what ever you've specified
to the page just before the closing form tag for the page. You must include
the script tags around your client side script yourself.

ClientScript.RegisterStartupScript(this.GetType(), "SomeScript",
"<script>alert(\"Hi there\");</" + "script>");
Apr 30 '06 #2
Alex Maghen wrote:
When I do this in my page...
ClientScript.RegisterStartupScript(this.GetType(), "SomeScript",
"alert(\"Hi there\");");

it doesn't work AND when I view source, the alert() line is dumped into the
HTML but with no <SCRIPT> block around it. Why would this be happening?


Because you haven't specified that it should add script tags.

ClientScript.RegisterStartupScript(this.GetType(), "SomeScript",
"alert(\"Hi there\");", true);
Apr 30 '06 #3

"Göran Andersson" <gu***@guffa.com> wrote in message
news:Or**************@TK2MSFTNGP02.phx.gbl...
Alex Maghen wrote:
When I do this in my page...
ClientScript.RegisterStartupScript(this.GetType(), "SomeScript",
"alert(\"Hi there\");");

it doesn't work AND when I view source, the alert() line is dumped into
the HTML but with no <SCRIPT> block around it. Why would this be
happening?


Because you haven't specified that it should add script tags.

ClientScript.RegisterStartupScript(this.GetType(), "SomeScript",
"alert(\"Hi there\");", true);


Cool, I didn't know that the new 2.0 version added tags for you. I should
pay more attention ;-) My earlier post refers to the old
Page.RegisterStartupScript which didn't add tags and I incorrectly assumed
that this was still the case.
Apr 30 '06 #4
VERY cool. And thanks!

Alex

"Tony B" wrote:

"Göran Andersson" <gu***@guffa.com> wrote in message
news:Or**************@TK2MSFTNGP02.phx.gbl...
Alex Maghen wrote:
When I do this in my page...
ClientScript.RegisterStartupScript(this.GetType(), "SomeScript",
"alert(\"Hi there\");");

it doesn't work AND when I view source, the alert() line is dumped into
the HTML but with no <SCRIPT> block around it. Why would this be
happening?


Because you haven't specified that it should add script tags.

ClientScript.RegisterStartupScript(this.GetType(), "SomeScript",
"alert(\"Hi there\");", true);


Cool, I didn't know that the new 2.0 version added tags for you. I should
pay more attention ;-) My earlier post refers to the old
Page.RegisterStartupScript which didn't add tags and I incorrectly assumed
that this was still the case.

Apr 30 '06 #5

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

Similar topics

2
2240
by: Madhav | last post by:
I have the following statements in my script. ---------------------------------------------------------- textToWrite = "<HTML> \n" + "<HEAD> \n" + "<TITLE>Calendar</TITLE> \n" + "<SCRIPT...
0
1132
by: Tony Hedge | last post by:
Hello, I'm using .NET 1.0 on W2K. In my web app solution I have the following hierarchy: -MyWeb.proj ---\Images ---\Styles ---\US -----Main.aspx -----\Images
1
1441
by: D. Shane Fowlkes | last post by:
I'm a fairly skilled traditional ASP/VB programmer and am learning .NET. I was (recently) surprised to read in a book about declaring and defining all my page Functions in <script...
8
5344
by: Brett Robichaud | last post by:
I understand how code-behind can handle events for a page, but can I call a code-behind method from within a <script> tag in my ASP.Net page, or can I only call methods defined in other <script>...
9
1703
by: sam.s.kong | last post by:
Hello! I have a JavaScript code like the following. <script> var s = "</script>"; ....
21
8487
by: hemant.singh | last post by:
Hello all, I am try'g to send window.location.href to the server script who will generate dynamic javascript according to the referral name comg in as param Now bcz <script language="javascript"...
12
62871
by: Iddo | last post by:
Hi, I am having a strange problem... I have an HTML file which has 2 script tags: 1) <script language="javascript" id="ABC" src="ABC.js" /> 2) <script id="general" language="javascript">...
44
2790
by: rhythmace | last post by:
W3C HTML validator passes this: .... <script type="text/javascript" src="foo.js"> <script type="text/javascript"> ....script in here... </script> ....
2
2047
by: -Karl | last post by:
Couls someone please advise me on this error. What I am trying to do is be able to convert an XML document into arrays. I read that the subs & functions have to be in <scripttags. Thanks! ...
0
7203
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
7281
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
7334
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...
1
6993
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
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.