Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSS Scroll Issue 3 93
Download a website to hdd 2 51
using php variable inside javascript 5 16
two layers of simple javascript validation 2 28
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

867 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

24 Experts available now in Live!

Get 1:1 Help Now