PC Review


Reply
Thread Tools Rate Thread

accessing a registered startup script in c# code

 
 
Andy B
Guest
Posts: n/a
 
      1st Jan 2008
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?



 
Reply With Quote
 
 
 
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      1st Jan 2008
"Andy B" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

>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

 
Reply With Quote
 
marss
Guest
Posts: n/a
 
      2nd Jan 2008
On 1 Січ, 21:49, "Andy B" <a_bo...@sbcglobal.net> wrote:
> 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




 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      2nd Jan 2008
"marss" <(E-Mail Removed)> wrote in message
news:3e0caa86-7f8c-49d0-830a-(E-Mail Removed)...

> 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

 
Reply With Quote
 
marss
Guest
Posts: n/a
 
      2nd Jan 2008
On 2 Січ, 16:03, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "marss" <marss...@gmail.com> wrote in message
>
> news:3e0caa86-7f8c-49d0-830a-(E-Mail Removed)...
>
> > 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
 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      2nd Jan 2008
"marss" <(E-Mail Removed)> wrote in message
news:fe47f71a-cda5-4b39-ae02-(E-Mail Removed)...

> 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

 
Reply With Quote
 
marss
Guest
Posts: n/a
 
      2nd Jan 2008
On 2 Січ, 23:32, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:

> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing a registered site Ms. Tiffany Windows Vista General Discussion 6 9th Jul 2008 04:19 AM
remove script registered using RegisterClientScriptBlock Steve Powell Microsoft ASP .NET 3 21st Jun 2005 09:41 AM
Script Err - class not registered Anil Bhattacharji Windows XP Internet Explorer 2 3rd Aug 2004 02:41 PM
Script error: Class not registered John Microsoft Outlook 1 25th Jul 2004 06:07 AM
Script error: Class not registered John Microsoft Outlook Discussion 0 24th Jul 2004 11:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:10 PM.