Solved

ScriptManager.RegisterClientScriptBlock not working

Posted on 2011-03-06
5
1,127 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:scm0sml
5 Comments
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 35046596
0
 

Author Comment

by:scm0sml
ID: 35046627
what has he done differently to what I am doing?
0
 
LVL 16

Expert Comment

by:BurnieP
ID: 35046858
Hi,

Try RegisterStartupScript insead :

ScriptManager.RegisterStartupScript(Me.Page, Me.GetType, "DisplayAlertaj", script, True);
0
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 500 total points
ID: 35047224
The last parameter (addScriptTags) is set to true; it appends script-tags to your script.
Since you have it already in your string you can set it to false or you could remove the script tags from the string.

I would remove the script tags from the string...
Public Sub JavascriptAlertAjax(ByVal message As String)
        Try
            Dim script = "DisplayAlert('" & message & "')"
            ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType, "DisplayAlertaj", script, True)
        Catch ex As Exception
            Throw
        End Try
    End Sub

Open in new window

0
 

Author Comment

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

which works fine.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

20 Experts available now in Live!

Get 1:1 Help Now