L
Lou
I'm using the Response Filter Class in MS KB article 811162
(http://support.microsoft.com/default.aspx?scid=kb;EN-US;811162) to
generate a static htm page from an asp.net template page being filled
from a database. The generated static pages are then streamed into
FreeTextbox editor for user edits.
I want to use a variable for the filename since each user will need a
separate temporary template page.
The system works fine for a hardcoded filename like addendum.htm but
yields the following error when I try to use a variable as the
filename.
How can I solve this?
Thanks for your help,
Lou
--------------
Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.
Compiler Error Message: BC30469: Reference to a non-shared member
requires an object reference.
Source Error:
Line 17:
Line 18: Dim strEmployeeKey as string
Line 19: strEmployeeKey=Session("EmployeeKey")
Line 20:
Line 21:
************************
Public Class ResponseFilter
Inherits Stream
Dim fs As FileStream
Dim m_sink As Stream
Dim m_position As Long
Sub New(ByVal sink As Stream)
Dim strEmployeeKey as string
strEmployeeKey=Session("EmployeeKey")
m_sink = sink
fs = New FileStream("D:\Program
Files\MEBIM\\Addendum" & strEmployeeKey & ".htm" ",
FileMode.OpenOrCreate, FileAccess.Write)
End Sub
Public Overrides ReadOnly Property CanRead() As
Boolean
Get
Return True
End Get
End Property
Public Overrides ReadOnly Property CanSeek() As
Boolean
Get
Return False
End Get
End Property
Public Overrides ReadOnly Property CanWrite() As
Boolean
Get
Return False
End Get
End Property
Public Overrides ReadOnly Property Length() As Long
Get
Return 0
End Get
End Property
Public Overrides Property Position() As Long
Get
Return m_position
End Get
Set(ByVal Value As Long)
m_position = Value
End Set
End Property
Public Overrides Function Seek(ByVal offset As Long,
ByVal direction As SeekOrigin) As Long
Return 0
End Function
Public Overrides Sub SetLength(ByVal length As Long)
m_sink.SetLength(length)
End Sub
Public Overrides Sub Close()
m_sink.Close()
fs.Close()
End Sub
Public Overrides Sub Flush()
m_sink.Flush()
End Sub
Public Overrides Function Read(ByVal buffer() As Byte,
ByVal offset As Int32, ByVal count As Int32) As Int32
Return m_sink.Read(buffer, offset, count)
End Function
Public Overrides Sub Write(ByVal buffer() As Byte,
ByVal offset As Int32, ByVal count As Int32)
' Write out the response to the browser.
m_sink.Write(buffer, 0, count)
m_sink.close
' Write out the response to the file.
fs.Write(buffer, 0, count)
' fs.close
End Sub
End Class
Sub Page_Init(Sender As Object, E As EventArgs)
Response.Filter = New ResponseFilter(Response.Filter)
End Sub
(http://support.microsoft.com/default.aspx?scid=kb;EN-US;811162) to
generate a static htm page from an asp.net template page being filled
from a database. The generated static pages are then streamed into
FreeTextbox editor for user edits.
I want to use a variable for the filename since each user will need a
separate temporary template page.
The system works fine for a hardcoded filename like addendum.htm but
yields the following error when I try to use a variable as the
filename.
How can I solve this?
Thanks for your help,
Lou
--------------
Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.
Compiler Error Message: BC30469: Reference to a non-shared member
requires an object reference.
Source Error:
Line 17:
Line 18: Dim strEmployeeKey as string
Line 19: strEmployeeKey=Session("EmployeeKey")
Line 20:
Line 21:
************************
Public Class ResponseFilter
Inherits Stream
Dim fs As FileStream
Dim m_sink As Stream
Dim m_position As Long
Sub New(ByVal sink As Stream)
Dim strEmployeeKey as string
strEmployeeKey=Session("EmployeeKey")
m_sink = sink
fs = New FileStream("D:\Program
Files\MEBIM\\Addendum" & strEmployeeKey & ".htm" ",
FileMode.OpenOrCreate, FileAccess.Write)
End Sub
Public Overrides ReadOnly Property CanRead() As
Boolean
Get
Return True
End Get
End Property
Public Overrides ReadOnly Property CanSeek() As
Boolean
Get
Return False
End Get
End Property
Public Overrides ReadOnly Property CanWrite() As
Boolean
Get
Return False
End Get
End Property
Public Overrides ReadOnly Property Length() As Long
Get
Return 0
End Get
End Property
Public Overrides Property Position() As Long
Get
Return m_position
End Get
Set(ByVal Value As Long)
m_position = Value
End Set
End Property
Public Overrides Function Seek(ByVal offset As Long,
ByVal direction As SeekOrigin) As Long
Return 0
End Function
Public Overrides Sub SetLength(ByVal length As Long)
m_sink.SetLength(length)
End Sub
Public Overrides Sub Close()
m_sink.Close()
fs.Close()
End Sub
Public Overrides Sub Flush()
m_sink.Flush()
End Sub
Public Overrides Function Read(ByVal buffer() As Byte,
ByVal offset As Int32, ByVal count As Int32) As Int32
Return m_sink.Read(buffer, offset, count)
End Function
Public Overrides Sub Write(ByVal buffer() As Byte,
ByVal offset As Int32, ByVal count As Int32)
' Write out the response to the browser.
m_sink.Write(buffer, 0, count)
m_sink.close
' Write out the response to the file.
fs.Write(buffer, 0, count)
' fs.close
End Sub
End Class
Sub Page_Init(Sender As Object, E As EventArgs)
Response.Filter = New ResponseFilter(Response.Filter)
End Sub