473,396 Members | 1,866 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.

accessing a registered startup script in c# code

I have this code in one of my methods:
ClientScript.RegisterStartupScript(GetType(), "AddNews",

"alert('Sorry! For some reason, the news article couldn't be added. Try
again later...');", true);
After it is registered, I will now need to make this script run. How do you
do that?

Jan 1 '08 #1
6 3971
"Andy B" <a_*****@sbcglobal.netwrote in message
news:OT**************@TK2MSFTNGP03.phx.gbl...
>I have this code in one of my methods:
ClientScript.RegisterStartupScript(GetType(), "AddNews",

"alert('Sorry! For some reason, the news article couldn't be added. Try
again later...');", true);
After it is registered, I will now need to make this script run. How do
you do that?

??? It will run when your page loads...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 1 '08 #2
On 1 Січ, 21:49, "Andy B" <a_bo...@sbcglobal.netwrote:
I have this code in one of my methods:
ClientScript.RegisterStartupScript(GetType(), "AddNews",

"alert('Sorry! For some reason, the news article couldn't be added. Try
again later...');", true);

Hi Andy

It does not execute while page is loading because of mistake in your
script. You can use single quotes to define a string in javascript
only if that string does not contain single quote itself.

Try this:
ClientScript.RegisterStartupScript(GetType(), "AddNews",
"alert(\"Sorry! For some reason, the news article couldn't be added.
Try again later...\");", true);

Regards,
Mykola
http://marss.co.ua


Jan 2 '08 #3
"marss" <ma******@gmail.comwrote in message
news:3e**********************************@f3g2000h sg.googlegroups.com...
You can use single quotes to define a string in javascript
only if that string does not contain single quote itself.
That's not true - all you need to do is escape the single quote within the
string, e.g.

ClientScript.RegisterStartupScript(GetType(), "AddNews", "alert('Sorry! For
some reason, the news article couldn\'t be added. Try again later...');",
true);
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 2 '08 #4
On 2 Січ, 16:03, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"marss" <marss...@gmail.comwrote in message

news:3e**********************************@f3g2000h sg.googlegroups.com...
You can use single quotes to define a string in javascript
only if that string does not contain single quote itself.

That's not true - all you need to do is escape the single quote within the
string, e.g.

ClientScript.RegisterStartupScript(GetType(), "AddNews", "alert('Sorry! For
some reason, the news article couldn\'t be added. Try again later...');",
true);

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
Hi Mark,

It is true, at least in that case. Try to test the example you
suggested and you'll see the problem.

Regards,
Mykola
http://marss.co.ua
Jan 2 '08 #5
"marss" <ma******@gmail.comwrote in message
news:fe**********************************@i7g2000p rf.googlegroups.com...
It is true, at least in that case. Try to test the example you
suggested and you'll see the problem.
Apologies for the typo...

ClientScript.RegisterStartupScript(GetType(), "AddNews", "alert('Sorry! For
some reason, the news article couldn\\'t be added. Try again later...');",
true);
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 2 '08 #6
On 2 Січ, 23:32, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
ClientScript.RegisterStartupScript(GetType(), "AddNews", "alert('Sorry! For
some reason, the news article couldn\\'t be added. Try again later...');",
true);
Well, it is a variant. Quite good variant :)

Regards,
Mykola
http://marss.co.ua
Jan 2 '08 #7

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

Similar topics

16
by: Neil Benn | last post by:
Hello, I'm looking at a small app which would need a very quick startup time for the Python interpreter. It doesn't do much (copying and caching of files, no GUI) but I need the Python...
4
by: Jesper | last post by:
Hi, I would like to issue three statements to the database (mysql v4.1) each time the server starts up. Is there any built in way to do this? Like a init file to put them in? At the moment I...
6
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is...
5
by: Vinod Kumar | last post by:
Hi All, Can I access a Javascript function written in an ASP.NET from the codebehind (C#) of that page? If yes, kindly give the code snippet to do this. Thanks and Regards Vinod Kumar
5
by: Ahmed | last post by:
Hi all, Is there any way to replace a script I registered in Page Load with the method Page.RegisterStartupScript
0
by: Nijazi Halimaji | last post by:
Hi Newsgroup I have written a .NET Component, made the check on "register for COM interop" in Build options, create a strong name and registered the assembly in the GAC. Accessing this...
6
by: Velislav | last post by:
Hi, I have a client script block, which is registered in my Page_Load. However a button may result in the need to change the script which I've registered. Obviously the OnClick event occurs...
3
by: MrDeej | last post by:
Hello! I am trying to make a startup script which selects a predefined TAB page from a form at startup. This is how i want it to be: I have a table which contains user-data. In this i have a...
3
by: traceable1 | last post by:
Is there a way I can set up a SQL script to run when the instance starts up? SQL Server 2005 SP2 thanks!
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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.