Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在代码隐藏中访问ascx中使用的变量_C#_.net_Visual Studio - Fatal编程技术网

C# 在代码隐藏中访问ascx中使用的变量

C# 在代码隐藏中访问ascx中使用的变量,c#,.net,visual-studio,C#,.net,Visual Studio,我有一个简单的.ascx页面,如下所示: <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ctl_dataLookup.ascx.cs" Inherits="ctl_dataLookup" %> <div> <h1>Data Lookup</h1> <p><%= d1 %></p> </div> 但是,在呈

我有一个简单的.ascx页面,如下所示:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ctl_dataLookup.ascx.cs" Inherits="ctl_dataLookup" %>

<div>
    <h1>Data Lookup</h1>

    <p><%= d1 %></p>
</div>
但是,在呈现页面时(System.Web.UI.WebControl.Label),最终的结果总是这样:


我已经看过无数关于堆栈溢出的例子,但是看起来我做的一切都是对的。。。出现这种情况有什么明显的原因吗?

尝试使用D1,而不是私有D1变量。 希望这能奏效


谢谢你。。。谢谢杰哈!
public partial class ctl_dataLookup : BaseDomainControl
{

        private string d1;
        public string D1 { get { return d1; } }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.Visible = false;
            this.DataBind();
        }

        public void DoDataLookup(int DomainId, string DomainName)
        {
            this.Visible = true;

            d1 = "TEST DOMAIN";
        }


}