Solved

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

Posted on 2009-04-01
3
2,830 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
  • 2
3 Comments
 
LVL 30

Expert Comment

by:third
Comment Utility
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
Comment Utility
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
Comment Utility
THANKS!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now