Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-04-01
3
Medium Priority
?
3,000 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

604 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