adding text to legend from code behind

2019-08-01 08:09发布

how can i add text to a legend from code behind

标签: c# .net legend
1条回答
劳资没心,怎么记你
2楼-- · 2019-08-01 09:06

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";
查看更多
登录 后发表回答