2

i want to write message through ScriptManager.RegisterStartupScript method . but am getting error in this statement.

my code
-------
ScriptManager.RegisterStartupScript(Me, Me.GetType, "temp", ("<script language='javascript'>alert(' No data in the database  ');</script>")), False)


error(in particular position)
-----
 , False)   error   -   end of the statement expected


 scriptmanager     Error 'System.Web.UI.Page.Friend ReadOnly Property ScriptManager As System.Web.UI.IScriptManager' is not accessible in this context because it is 'Friend'.  

Help me to correct the problem. am new to javascript

3 Answers 3

3

Strange message, can you try the following:

System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(@"<script language='javascript'>");
sb.Append(@"alert(' No data in the database  ');");
sb.Append(@"</script>");

If (Not ClientScript.IsStartupScriptRegistered("JSScript")) Then
        ClientScript.RegisterStartupScript(Me.GetType(), "JSScript", sb.ToString());
Sign up to request clarification or add additional context in comments.

1 Comment

am using vb.net. please help me to convert it in vb.net
0

This works for me:

Dim js As String = "alert('TGIF!!.')"
ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType, "popup", js, True)

Comments

0

I know this is an old tread but thought i would mention that i had the same problem using code from a .net 3.5 in 2.0, So it is finding a different definition of ScriptManager that is not the same as what I needed.

Once i changed the project to 3.5 it worked fine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.