2

应该怎么做才能解决访问问题?

标记:

<%@ 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";
    }
}

错误:

当前上下文中不存在名称“deneme”

4

1 回答 1

1

试试这个,它应该工作。

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

代码背后

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();

}
}
于 2013-02-10T23:50:11.123 回答