gpt4 book ai didi

asp.net - 从 web 应用程序项目中的 aspx 页面访问代码隐藏的属性

转载 作者:行者123 更新时间:2023-12-04 17:02:02 24 4
gpt4 key购买 nike

我有房产 x 在我的 Web 应用程序项目中的代码隐藏文件中。它给了我编译时错误,而它在网站项目中没有给出任何错误

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" 
Inherits="test.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%= x2 %>
<%# x2 %>
</div>
</form>
</body>
</html>

代码隐藏文件:
using System;
namespace test
{public partial class WebForm1 : System.Web.UI.Page
{
public int x2 = 2;
protected void Page_Load(object sender, EventArgs e)
{
}
}
}

当我在我的网站项目中使用相同的技术时它工作正常
请帮忙
谢谢

最佳答案

检查 后面的代码中是否还有其他错误WebForm1.aspx.cs。
像缺少引用或任何其他编译错误。

关于asp.net - 从 web 应用程序项目中的 aspx 页面访问代码隐藏的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47634617/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com