Question

how can i add text to a legend from code behind

Was it helpful?

Solution

Assuming you're talking about the HTML Legend Tag and using C# in an ASP.NET site. You can give it an ID and a runat="server" then you can access it from the code behind by name and change its text property.

<form id="form1" runat="server">
<fieldset>
<legend id="myLegend" runat="server">Personalia:</legend>
Name: <input type="text" size="30" /><br />
Email: <input type="text" size="30" /><br />
Date of birth: <input type="text" size="10" />
</fieldset>
</form>

Then in the code behind:

myLegend.InnerText = "Foo";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top