asp.net - 从带有命名空间的 ASPX 页面引用代码隐藏函数
问题描述
我有一个非常不寻常的问题,希望得到帮助。我在 VS 2019 中有一个 Web 应用程序。
我正在尝试创建一个在其自己的命名空间中运行的页面,以便我可以与其他网站共享它。下面是一个简单的示例页面和代码。
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="test1.aspx.vb" Inherits="xxxx.test1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%= Myfunc1() %>
</div>
</form>
</body>
</html>
Namespace xxxx
Public Class test1
Inherits System.Web.UI.Page
Public Function Myfunc1() As String
Myfunc1 = "Hello"
End Function
End Class
End Namespace
编译显示 <%= Myfunc1() %> 为 MyFunc1 not found。
如果我从后面的代码中删除“命名空间 xxxx”并将 Inherits="xxxx.test1" 更改为 Inherits "TestWebsite.test1"(TestWebsite 是 Web 项目的命名空间,也是添加测试页时的默认设置)。此代码编译并正常工作。
对于如何实现使页面的名称空间独立于网站项目的目标,我将不胜感激。
谢谢保罗
解决方案
推荐阅读
- javascript - Firebase 身份验证 - 重置密码不显示任何操作 - Javascript
- ruby-on-rails - 如何在 Rails 中向现有用户表单添加多个角色
- stl - sysmac studio 中的 Stl 语言 4bytes 浮动(真实)
- microsoft-teams - 如何将 Power App 添加到 Teams 会议中,读取会议信息?
- vb.net - 在 .CSV 中导出带有多行行的 datagridview
- sql - SQL 选择确切的行
- c++ - 类没有成员函数
- r - 错误:找不到闪亮的会话对象
- angular - 如何在 switchMap 中等待 Observable?
- react-native - React Native Sortable List JSX 元素类不支持属性