Hey all i have this code here:
ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "showNotifier", ";$(function() {showNotifier(3000,'#cf5050','" & msg & "');});", True)
That i am wanting to place inside a class file like so:
Public Class topMsgNotifyer
Public Shared Sub show(ByVal delay As Integer, ByVal colorOfBox As String, ByVal message As String)
Try
ScriptManager.RegisterClientScriptBlock(Me.Page, GetType(String), "showNotifier", ";$(function() {showNotifier(" & delay & ",'" & colorOfBox & "','" & message & "');});", True)
Catch ex As Exception
End Try
End Sub
End Class
And of course it has a problem with Me.Page inside the class file.
I can get the current page name by doing this:
Dim pageName = Path.GetFileName(Request.Path)
How can i correct this when calling that class sub from a asp.net page instead of calling it on the page itself?
You could pass the Page object to your show() method, however, a better approach would be to create a class that is a BasePage class, in which your pages inherit from. In that class, make you show() method. Consequently, every page that inherits this BasePage will have access to that method, and Me.Page will be available.
Passing the Page object:
call it: