Correct : 'Public Function IsStartupScriptRegistered(key As String) As Boolean' is obsolete

I am working in VB.Net and am getting the following error..can some body help me correcting this...

my code is
If (Not IsStartupScriptRegistered("Startup")) Then
                RegisterStartupScript("Startup", scriptString.ToString)
            End If


BC40000 : 'Public Function IsStartupScriptRegistered(key As String) As Boolean' is obsolete: 'The recommended alternative is ClientScript.IsStartupScriptRegistered(string key). http://go.microsoft.com/fwlink/?linkid=14202' in Reports.aspx.vb(41, 0)

BC40000 : 'Public Overridable Sub RegisterStartupScript(key As String, script As String)' is obsolete: 'The recommended alternative is ClientScript.RegisterStartupScript(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202' in Reports.aspx.vb(42, 0)

KerauAsked:
Who is Participating?
 
SameerJagdaleConnect With a Mentor Commented:
i guess you are using vb.net
try this
ClientScript.RegisterStartupScript(GetType(Page), "Startup",scriptString.ToString)
0
 
SameerJagdaleCommented:
the 2 functions are obsolete, however it will not stop you from running the application i guess.
you can change the functions to the recommended one like for IsStartupScriptRegistered("Startup")) use ClientScript.IsStartupScriptRegistered("Startup"))
and same for the second one.
0
 
KerauAuthor Commented:
Thanks Sameer, You are correct it doesn't stop me running the application but need to eliminate the warning as well ...so i tried this

IsStartupScriptRegistered("Startup")) use ClientScript.IsStartupScriptRegistered("Startup")) works fine ..........but  when i use change the second line
RegisterStartupScript("Startup", scriptString.ToString) to ClientScript.RegisterStartupScript("Startup", scriptString.ToString)

I get the following error..
overload resolution failed because no accessible 'RegisterStartupScript' accepts this number of arguments :(
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
SameerJagdaleCommented:
try this:
ClientScript.RegisterStartupScript(typeof(string),"Startup", scriptString.ToString)
0
 
KerauAuthor Commented:
sure thanks..i will use this and get back to u asap..:)
0
 
KerauAuthor Commented:
says 'string' is a class type and can't be use as an expression
0
 
SameerJagdaleCommented:
change the first parameter to:
typeof(Page) and try
0
 
KerauAuthor Commented:
It says type is expected ..suggests me as typeof(Page)Is??????
0
 
KerauAuthor Commented:
I am using VB.net :).

just a quick question...which one would you prefer /conventional way in a vb

Dim urlString As String = ""

OR

Dim urlString  = ""
0
 
SameerJagdaleConnect With a Mentor Commented:
Dim urlString As String = ""

if you use
Dim urlString  = ""

urlString would be considered as an object not a string.. ultimately string is an object but then it is not strongly typed.
thanks
0
 
KerauAuthor Commented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.