在ASP.NET 2.0中可以同是调用VB,C#中的类.
By default, the App_Code directory can only contain files of the same language. However, you may partition the App_Code directory into subdirectories (each containing files of the same language) in order to contain multiple languages under the App_Code directory. To do this, you need to register each subdirectory in the Web.config file for the application. 可以在WEB.CONFIG中申明一个用于放置其他语言的子目录.![Snap1.jpg](http://www.maxer.cn/blog/content/binary/Snap1.jpg)
web.config
-----------------------------------------------------------------------------------------------------------<configuration> <system.web> <compilation> <codeSubDirectories> <add directoryName="Subdirectory"/> // Your custom dirctionory which to contain the deferenet lanuage class such as vb </codeSubDirectories> </compilation> </system.web></configuration>-----------------------------------------------------------------------------------------------------------customClass.cs
-----------------------------------------------------------------------------------------------------------using System;public class CustomClass{ public String GetMessage(String input) { return "Hello " + input; }}-----------------------------------------------------------------------------------------------------------SubDirectory/customClass.vb
-----------------------------------------------------------------------------------------------------------Imports Microsoft.VisualBasicPublic Class CustomClass2 Public Function GetMessage(ByVal name As String) As String Return "Hello from VB " & name End FunctionEnd Class-----------------------------------------------------------------------------------------------------------page.aspx-----------------------------------------------------------------------------------------------------------<%@ page language="C#" %>
<script runat="server"> void Button1_Click(object sender, EventArgs e) { CustomClass c = new CustomClass(); Label1.Text = c.GetMessage(TextBox1.Text); CustomClass2 c2 = new CustomClass2(); Label2.Text = c2.GetMessage(TextBox1.Text); }</script><html><head> <title>ASP.NET Inline Pages</title></head><body> <form id="Form1" runat="server"> <h1>Welcome to ASP.NET 2.0!</h1> <b>Enter Your Name:</b> <asp:TextBox ID="TextBox1" Runat="server"/> <asp:Button ID="Button1" Text="Click Me" OnClick="Button1_Click" Runat="server"/> <br /> <br /> <asp:Label ID="Label1" Runat="server" /> <br /> <asp:Label ID="Label2" Runat="server" /> </form></body></html>-----------------------------------------------------------------------------------------------------------