Solved

System.Web.UI.Page.RegisterStartupScript(string, string)' is obsolete

Posted on 2009-04-01
3
2,912 Views
Last Modified: 2012-05-06
I get this error when I compile:
warning CS0618: 'System.Web.UI.Page.RegisterStartupScript(string, string)' is obsolete: 'The recommended alternative is ClientScript.RegisterStartupScript(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202'

I need to replace it...can someone give me the correct syntax to do so?
Here is my code.
this.RegisterStartupScript("sf", "<script language=\"javascript\">setTimeout(function(){SetFocus(document.forms[0]." +
    dtArrivalDate.ClientID + ",'Y');},100);</script>");

Open in new window

0
Comment
Question by:cenetadmin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 30

Expert Comment

by:third
ID: 24040138
use,


Page.ClientScript.RegisterStartupScript(this.GetType(), "sf", "<script language=\"javascript\">setTimeout(function(){SetFocus(document.forms[0]." +
    dtArrivalDate.ClientID + ",'Y');},100);</script>");
0
 
LVL 30

Accepted Solution

by:
third earned 500 total points
ID: 24040187
instead of adding the script tags on the function, i usually just set the last parameter to true.

Page.ClientScript.RegisterStartupScript(this.GetType(), "sf", "setTimeout(function(){SetFocus(document.forms[0]." + dtArrivalDate.ClientID + ",'Y');},100);", true);
0
 

Author Closing Comment

by:cenetadmin
ID: 31565342
THANKS!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question