Link to home
Create AccountLog in
Avatar of scm0sml
scm0sml

asked on

ScriptManager.RegisterClientScriptBlock not working

As you can see in my function below, I did use ClientScript.RegisterClientScriptBlock and it worked fine.

I have now added an update panel to one of my pages so need this javascript alret function to work in there so have created an ajax version.

What do I need to do to:
ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType, "DisplayAlertaj", script, True)

As it isn't currently doing anything?

Thanks in advance
Public Sub JavascriptAlertAjax(ByVal message As String)
        Try
            Dim script = "<script language='JavaScript'> "
            script += "DisplayAlert('" & message & "')"
            script += "</script>"
            'ClientScript.RegisterClientScriptBlock(Me.GetType, "DisplayAlert", script)
            ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType, "DisplayAlertaj", script, True)
        Catch ex As Exception
            Throw
        End Try
    End Sub

Open in new window

Avatar of Rajkumar Gs
Rajkumar Gs
Flag of India image

Avatar of scm0sml
scm0sml

ASKER

what has he done differently to what I am doing?
Hi,

Try RegisterStartupScript insead :

ScriptManager.RegisterStartupScript(Me.Page, Me.GetType, "DisplayAlertaj", script, True);
ASKER CERTIFIED SOLUTION
Avatar of Albert Van Halen
Albert Van Halen
Flag of Netherlands image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of scm0sml

ASKER

I know have:
Dim script = ""
            script += "DisplayAlert('" & message & "')"            
            ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType, "DisplayAlertAJ", script, True)

which works fine.