Write a program to change color of Label text control programmatically in Asp.Net.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lboutput" runat="server" Text="Welcome
in Code Solution "></asp:Label>
<br />
<asp:Button ID="btnred" runat="server" Text="" BackColor="Red"
onclick="btnred_Click" />
<asp:Button ID="btnblue" runat="server" Text="" BackColor="Blue" onclick="btnblue_Click" />
<asp:Button ID="btngreen" runat="server" Text="" BackColor="Green"
onclick="btngreen_Click" />
</div>
</form>
</body>
</html>
Code :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
public partial class changelabelcolor :
System.Web.UI.Page
{
protected void btnred_Click(object sender, EventArgs e)
{
lboutput.ForeColor = Color.Red;
}
protected void btnblue_Click(object sender, EventArgs e)
{
lboutput.ForeColor = Color.Blue;
}
protected void btngreen_Click(object sender, EventArgs e)
{
lboutput.ForeColor = Color.Green;
}
}