tags:

views:

230

answers:

2

ASP.NET C#

how do i add a title attribute to a panel (div) in the c# code behind file?

+1  A: 

In your aspx page:

<asp:panel id="MyPanel" runat="server"></asp:panel>

In your codebehind:

protected void Page_Load(object sender, EventArgs e)
{
    MyPanel.Attributes.Add("title", "A title for this div");
}
Tim S. Van Haren
A: 

Add a runat="server" attribute to your div, then you can access it like any other ASP.NET control.

markup:

<div id="myDiv" runat="server"></div>

code-behind:

myDiv.Attributes["title"] = "some title";
M4N