Tôi cần phải sử dụng cấu trúc lớp trong asp cổ điển. Tôi đã viết sau ba lớp.Cấu trúc lớp trong asp cổ điển
Category.asp
<%
Class Category
Private NameVar
Public Property Get Name()
Name = NameVar
End Property
Public Property Let Name(nameParam)
NameVar = nameParam
End Property
End Class
%>
Item.asp
<%
Class Item
Private NameVar
Private CategoryVar
Public Property Get Name()
Name = NameVar
End Property
Public Property Let Name(nameParam)
NameVar = nameParam
End Property
Public Property Get Category()
category = categoryVar
End Property
Public Property Let Category(categoryParam)
CategoryVar = categoryParam
End Property
End Class
%>
Test.asp
<%
Dim CategoryVar
Set CategoryVar = New Category
CategoryVar.Name = "Weight"
Dim ItemVar
Set ItemVar = New Item
ItemVar.Name = "kg"
ItemVar.Category = CategoryVar
%>
<html>
<head>
<title>UoM Componet Testing</title>
</head>
<body>
<%= ItemVar.Name %><br/>
</body>
</html>
Khi tôi chạy mã này, tôi đã tìm thấy một số vấn đề. Lỗi là:
Microsoft VBScript runtime (0x800A01B6) Đối tượng không hỗ trợ tài sản hoặc phương pháp:.? 'CategoryVar"
Làm thế nào có thể giải thích điều này Xin hãy giúp tôi
Bạn đã thử 'Đặt ItemVar.Category = CategoryVar'? –
tôi đã sao chép lỗi của bạn, thật lạ! – Rafael