RSS
热门关键字:  下载  cms  模版  开源  dedecms
当前位置 :| 主页 > 站长学院 > Asp.Net教程 >

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

来源:不详 作者:未知 时间:2006-07-28 Tag: 点击:
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>


最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
热点关注
相关文章