Define a class inside page
<%@ page language="vb" runat="server" %>
<script runat="server">
Public Class Book
Private _Title As String
Private _Isbn As Integer
Private _Price As Decimal
Public Sub New()
_Title = "title"
_Isbn = 999999999
End Sub
Public ReadOnly Property TitleInfo As String
Get
Return _Title & " <i>(ISBN: " & _Isbn & ")</i>"
End Get
End Property
Public ReadOnly Property Title As String
Get
Return _Title
End Get
End Property
Public ReadOnly Property Isbn As Integer
Get
Return _Isbn
End Get
End Property
Public Property Price As Decimal
Get
Return _Price
End Get
Set(value As Decimal)
_Price = value
End Set
End Property
End Class
Sub Page_Load()
Dim MyBook As New Book()
Response.Write("<b>New book 'MyBook' created.</b>")
MyBook.Price = "39.99"
Response.Write("<br/>Title info: " & MyBook.TitleInfo)
Response.Write("<br/>Price: $" & MyBook.Price & "<br/>")
End Sub
</script>
Related examples in the same category