博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ASP.NET 2.0学习笔记之Code Directory
阅读量:7210 次
发布时间:2019-06-29

本文共 2622 字,大约阅读时间需要 8 分钟。

在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

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.VisualBasic
Public Class CustomClass2
    Public Function GetMessage(ByVal name As String) As String
        Return "Hello from VB " & name
    End Function
End 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>
-----------------------------------------------------------------------------------------------------------

cptrk.ashx?id=2db342cd-96f2-4acc-baa0-450b56b17757

转载于:https://www.cnblogs.com/Maxer/archive/2006/03/27/360196.html

你可能感兴趣的文章
Linux系统安装phpMyAdmin
查看>>
我的友情链接
查看>>
EXAM2
查看>>
你的努力终将被光芒环绕
查看>>
有用的浏览器插件
查看>>
redhat linux 5 nfs
查看>>
Application Transport Security has blocked a clear
查看>>
我的友情链接
查看>>
不能忘记的一段日子
查看>>
驯服 Tiger: 并发集合
查看>>
优化MySQL的数据库性能的八种方法
查看>>
企业应用的Ant模组编译环境
查看>>
使用Maven管理Eclipse Java项目
查看>>
让Jacob从当前路径读取dll文件及相关打包方法
查看>>
我的友情链接
查看>>
Redis 集群方案
查看>>
Linux下查看软、硬raid信息的方法
查看>>
基本控件Password控件
查看>>
linux下命令集合
查看>>
[转载] 山楂树之恋——01-03
查看>>