how to change color of Label text control programmatically in Asp .Net
Source Code
<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 />
<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 behind (C#):-
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 Page_Load(object
sender, EventArgs e)
{
}
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;
}
}
Out put:-
how to change color of Label text control programmatically in Asp .Net
Reviewed by NEERAJ SRIVASTAVA
on
12:06:00 AM
Rating:
No comments: