解决访问问题应采取什么措施?

标记:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Header.ascx.cs" Inherits="Version_2.Themes.Anatema.Header" %>

<%= deneme %>

码:
namespace Version_2.Themes.Anatema
{
    public partial class Header : UserControl
    {
        public string deneme = "asd";
    }
}

错误:

最佳答案

试试这个,它应该起作用。

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="user.ascx.cs" Inherits="user" %>
<asp:Label ID="Label1" runat="server">
<%=test%>
</asp:Label>

CODE BEHIND
using System;

public partial class user : System.Web.UI.UserControl{

public string test = "This is a test";
protected void Page_Load(object sender, EventArgs e){
    this.DataBind();

}
}

关于c# - UserControl .ascx变量访问,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14801804/

10-11 22:53
查看更多