Solved

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

Posted on 2009-04-01
3
2,880 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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

776 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