ASP.NET Web Forms > Label and Literal

Label control from the server side code in ASP.NET Web Forms

How to specify the text of the Label control from the server side code?


In case we need to dynamically change the text of the asp:Label you can use this approach. 

ASPX page
<p><asp:Label ID="Label2" runat="server" Text="My second Label"></asp:Label></p> 
CODE BEHIND
protected void Page_Load(object sender, EventArgs e) 
{
// writeing text from code behind
Label2.Text = "Written from code behind";
}

Specify the Text property from the code behind that will write the specified text on the web page

 Views: 2570 | Post Order: 8



Write for us






Hosting Recommendations