在ASP+ 中我们如何使用 Class 而不是组件

在ASP+ 中我们如何使用 Class 而不是组件

在ASP+ 中我们如何使用 Class 而不是组件
/*
豆腐制作 都是精品
http://www.asp888.net 豆腐技术站
如果您转贴 本文 请 保留版权信息
更多文章 都在 豆腐技术站
*/
asp+ 中我们有办法使用 预编译(pre-release)的代码 而不是 已经编译好的 二进制代码(build-in) 的组件
下面我们来看看一个例子

你可能会用到类似下面的代码:
<%@ Assembly src="test.cs" %> // Compile C# class
<%@ Assembly src="test.vb" %> // Compile VB class
在 代码的最上方 我们使用这样的 代码告诉编译器 把 文件中包含的 Class 编译到asp+ 的页面中

test.cs:

public class MyClass {

public string SaySomething() {
return "豆腐制作 都是精品";
}
}
test.vb:
public class test
readonly Property SaySomething() as string
get
SaySomething="豆腐制作 都是精品"
end get
end Property
end class

test.aspx:

<%@ Assembly Src="test.vb" %>

<html>
<script language="VB" runat=server>

Sub Page_Load(Sender as Object, E as EventArgs)

Dim Temp as New test
lblMsg.Text = temp.SaySomething()

End Sub

</script>

<body>
<asp:label id="lblMsg" runat=server/>
</body>
</html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值