你可能會用到類似下面的代碼:
<%@ 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()