ASP.NET control to render a <div>

空扰寡人 提交于 2019-12-03 22:05:15

I think you need HtmlGenericControl class. It has a constructor which accepts a string variable which initializes a new instance of the HtmlGenericControl class with the specified tag:

var div = new HtmlGenericControl("div");

It is also has InnerHtml and InnerText properties (you mentioned this in a comment to the previous answer).

Of course: ASP.NET has a built-in control called Panel!

And you may use it as follows:

<asp:Panel ID="myPanel" runat="server">
    <!-- Other markup here like client and server controls/elements -->
</asp:Panel>

Try the Panel control.

Eyad Eyadian

Try this:

<div class="myclass">
<asp:Literal ID="mytext" runat="server"></asp:Literal>
</div>

Set your text inside Literal, which renders without html tag

<asp:Panel>
<div id="NoRecords" runat="server" visible="false">No records are available.</div>
</asp:Panel>

Code-Behind

 protected void MyRepeater1_PreRender(object sender, EventArgs e)
{
    if (MyRepeater1.Items.Count == 0)
    {
        NoRecords.Visible = true;
    }
    else
    {
        NoRecords.Visible = false;
    }
}
div runat="server" id="myserversideDiv" 

my inner text here. It has inner text and inner html property and most of asp.net server control property. Try that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!