.Net Practical 18


Practical : 18
Subject : .Net

Aim : Write a program to change color of Label text, control programmatically in Asp .Net. 



Source Code :
//file.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pra18.aspx.cs" Inherits="dotnet008asp.pra18" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>pratik008</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Label ID="Label1" runat="server" Text="change to red"></asp:Label>
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="change" />
        </div>
    </form>
</body>
</html>

//file.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace dotnet008asp
{
    public partial class pra18 : System.Web.UI.Page
    {
        protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.ForeColor = System.Drawing.Color.Red;
        }
    }
}
Output : 



Pratik Boghani

Author & Editor

Life is all about the next step.

0 comments:

Post a Comment