Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.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/3/sockets/2.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控件页中呈现html_C#_Asp.net_Html_Ascx - Fatal编程技术网

C# 无法在ascx控件页中呈现html

C# 无法在ascx控件页中呈现html,c#,asp.net,html,ascx,C#,Asp.net,Html,Ascx,这是我的ascx控制页面代码 <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Menu.ascx.cs" Inherits="CrossQueue.Web.Menu" %> <asp:Label ID="lblMenu" runat="server"></asp:Label> "); } else if(dr[“MenuName”].ToString()=“User”) {

这是我的ascx控制页面代码

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Menu.ascx.cs" Inherits="CrossQueue.Web.Menu" %>
<asp:Label ID="lblMenu" runat="server"></asp:Label>

");
}
else if(dr[“MenuName”].ToString()=“User”)
{
menuHtml。追加(“”);
}
}
menuHtml。追加(“”);
menuHtml。追加(“”);
menuHtml。追加(“”);
}
lblMenu.Text=menuHtml.ToString();
}
}

当我加载页面时,我只看到一个html代码以文本形式打印,而不是呈现。有人能指出可能的错误吗

您可以通过
分配ID
和设置
runat=“server”
而不是标签来访问
div
服务器,并设置其内部html=menuHtml.ToString()


div1.InnerHTML=menuHtml.ToString();

您可以使用文字而不是标签

看到这个了吗 更改标签

<asp:Label ID="lblMenu" runat="server"></asp:Label>

字面上

<asp:Literal ID="lblMenu" runat="server" EnableViewState="false"></asp:Literal>


相关帖子:TL;DR:ASP.NET
Label
控件不用于嵌入HTML标记。您得到的确切错误是什么!!!请给出详细信息!!!Prahalad实际上是ascx控件页面Yes bro!!!对不起!!!不需要引入额外的
div
<asp:Label ID="lblMenu" runat="server"></asp:Label>
<asp:Literal ID="lblMenu" runat="server" EnableViewState="false"></asp:Literal>