Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp.net 4.0 vb response.write does not work in Module

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
0
36
US
I have 2 issues as shown in the code below in RED
Response' is not declared. It may be inaccessible due to its protection level..
Session' is not declared. It may be inaccessible due to its protection level.
Seesion vars don't work in modules either.
I want to be able to show a popup error window if there is something wrong in sub or function in a module. I have a majority of my code in the module since I call Stored Procedures and a lot of functions I created.

Code:
    Private Function ErrorTrap(ByVal ModuleCameFrom, ByVal ErrorMesssage, ByVal ErrorTitle)

        Dim strJScript As String
        strJScript = "<script language=javascript>"
        strJScript += "window.open('ErrorScreen.aspx',null,'height=150, width=430,status= no, resizable= no, scrollbars=no, toolbar=no,location=center,menubar=no, top=100, left=300');"
        strJScript += "</script>"
        [COLOR=red] Response.Write(strJScript) [/color]

        ErrorTrap = WriteToEventLog(ModuleCameFrom, ErrorMesssage, [COLOR=red]Session("UserLastName"), Session("UserFirstName")[/color])

    End Function
[/code

DougP
 
First, never use Response.Write unless for debugging purposes, but even that is a rare occasion.
Second, why use a module, use classes, remember, this is .NET not classic VB and asp.net
Third, when you are in a class or module, basically any object that is NOT a page you need to use:
Code:
HttpContext.Current.Session()... etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top