Thursday 28 February 2013

How to change label color from code behind page in asp.net

Code Behind page:

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class demoColor : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Label1.BackColor = Color.Red;
        this.Label1.Text += "some text to output.";
    }
}

.aspx Page:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="demoColor.aspx.cs" Inherits="demoColor" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>

0 comments:

Post a Comment


                                                            
 
Design by Abhinav Ranjan Sinha