Hi,
I am trying to write a detailed logging system for a site. The client
basically wants us to save the values of the properties on the page every
time someone presses a save button.
I have written the following function that formats the properties of a basic
class and rreturns it as a formatted string - but it does not work when I
try and pass it the Page class - it displays the error 'Object not set to an
instance....']
Anybody any ideas how I should do this?
Thanks in advance,
Stu
--/ snip /--
'THE PAGE
Public Class Test
Inherits System.Web.UI.Page
private m_Test as string="My test text"
Public Property Test1() As String
Get
Test1 = m_Test1
End Get
Set(ByVal Value As String)
m_Test1 = Value
End Set
End Property
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim log As New clsLogAction
Dim log As New clsLogAction
Response.Write(log.LogAction(Me))
End Sub
End Class
'The Log class
Class LogAction
Public Function returnValues(ByVal obj As Object) As String
Dim sb As New System.Text.StringBuilder
For Each iField As System.Reflection.FieldInfo In
obj.GetType.GetFields(BindingFlags.NonPublic Or BindingFlags.Instance)
sb.Append(iField.Name.ToString + "|" +
iField.GetValue(obj).ToString + vbCrLf)
Next
Return sb.ToString
End Function
End Class