oppure ho questa funzione

codice:
    '----------------------------------------------------------------
    'scrive un messaggio nel client
    '----------------------------------------------------------------
    Public Sub MsgBox(ByVal This As System.Web.UI.Page, ByVal s$)
        s = s.Replace("\", "\\")
        s = s.Replace(vbNewLine, "\n")
        s = s.Replace("'", "\'")

        s = String.Format("var func = function(){{alert('{0}');}};var oldonload = window.onload;if (typeof window.onload != 'function') {{window.onload = func;}}else {{window.onload = function() {{oldonload();func();}}}}", s)

        Dim ScriptString$ = ""
        ScriptString += "<script type=""text/javascript"" >" & vbCrLf
        ScriptString += s & vbCrLf
        ScriptString += "</script>" & vbCrLf
        'This.RegisterStartupScript("clientscript", ScriptString)
        This.ClientScript.RegisterStartupScript(This.GetType, "messagebox", s, True)



    End Sub
e la richiamo con:
Dim messaggio$ = "Questa" & vbNewLine & "è '\una\' ""prova"" xx"
libreria.MsgBox(Me, messaggio)