ASP-VB Running Javascript from class object

62 Views Asked by At

I am trying to create a function which displays a javascript-based notification. I already have the javascript code but I am trying to make it as a function in a class library but I don't know what to add in the return value, any ideas?

    Shared Function PNotify(ByVal type As String, ByVal title As String, ByVal message As String) As String
    Dim page As Page = HttpContext.Current.Handler
    page.ClientScript.RegisterStartupScript(HttpContext.Current.GetType, "", "new PNotify({title: '" & title & "', text: '" & message & "', type: '" & type & "', styling: 'bootstrap3'});")
    return ???
    End Function
1

There are 1 best solutions below

1
Westonsupermare On

Why have it return anything at all? If you really feel like returning something, change it to a Boolean function and return true if it worked and false if it didn't (try catch, maybe?).