asp-classic – 经典asp中的类结构
发布时间:2020-12-16 07:16:27 所属栏目:asp.Net 来源:网络整理
导读:我需要在经典的asp中使用类结构.我写了三节课. Category.asp %Class Category Private NameVar Public Property Get Name() Name = NameVar End Property Public Property Let Name(nameParam) NameVar = nameParam End PropertyEnd Class% Item.asp %Class
我需要在经典的asp中使用类结构.我写了三节课.
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> 当我运行此代码时,我发现了一些问题.错误是:
怎么解释这个?请帮我. 解决方法
在VBScript中,如果您知道属性将包含对象引用,则必须使用
Property Set 语句定义它.此外,在为变量分配对象引用时,必须使用
Set 语句.考虑到这一点,需要进行以下更改:
Item.asp Class Item '<snip> Public Property Get Category() ' Add Set here Set category = categoryVar End Property ' Change "Property Let" to "Property Set" Public Property Set Category(categoryParam) Set CategoryVar = categoryParam End Property End Class TEST.ASP <% ' <snip> ItemVar.Name = "kg" Set ItemVar.Category = CategoryVar %> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 如何从codebehind访问web.config的httpRuntime部
- asp.net – 和debug =“false”有什么区别?
- asp.net-mvc – 有没有办法从控制器A调用控制器B返回Action
- .net – WebApi传输字节数组为空
- asp.net – 在类库中引用RoleProvider
- asp.net – 如何从AJAX调用非静态方法?
- asp.net-mvc – 单元测试Url.Action(使用Rhino Mocks?)
- entity-framework – 此版本的Entity Framework核心软件包管
- asp.net-mvc – ValidateInput(false)和AllowHtml属性仍导致
- asp.net-mvc-3 – 向@ Html.ValidationSummary添加错误消息
推荐文章
站长推荐
热点阅读