RegisterStartupScript doesn't work at all!

A

AmitKu

The function simply doesn't add anything to my source.

I've added the following:

ClientScript.RegisterStartupScript( this.GetType(),
"SomeScript","<script>alert(\"Hi there\");</" + "script>" );

and not a thing is added to my asp file upon view source.

What am I doing wrong?


Thanks in advance,
Amit
 
L

Laurent Bugnion

Hi,
The function simply doesn't add anything to my source.

I've added the following:

ClientScript.RegisterStartupScript( this.GetType(),
"SomeScript","<script>alert(\"Hi there\");</" + "script>" );

and not a thing is added to my asp file upon view source.

What am I doing wrong?


Thanks in advance,
Amit

It works fine for me. Note that it's unnecessaty to break the </script>
end tag in two, I guess you saw that in old JavaScript code, but you're
on the server here, it's not needed.

Try to create a very simple web app, and add this code in OnInit, and
execute it.

Laurent
 
M

Mark Rae

I've added the following:

In which Page method have you added it...?
What am I doing wrong?

Try this in your Page_Load:

ClientScript.RegisterStartupScript(this.GetType(), "SomeScript",
"<script>alert('Hi there');</script>");
 
J

jjoy

You need to have a Form server control on your page for this to work.
Perhaps that's your issue. It's burned me in the past.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top