.Net Practical 20


Practical : 20
Subject : .Net

Aim : Write a program to increase and decrease font size programmatically.

Source Code :
//file.aspx

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

<!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="Pratk Boghani" Font-Size="20"></asp:Label>
        </div>
        <p>
            <asp:Button ID="Button1" runat="server" Text="--" OnClick="Button1_Click" />
            <asp:Button ID="Button2" runat="server" Text="++" OnClick="Button2_Click" />
        </p>
    </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 pra20 : System.Web.UI.Page
    {
        protected void Button1_Click(object sender, EventArgs e)
        {
            int currentsize = Convert.ToInt32(Label1.Font.Size.ToString().Replace("pt",""));
            Label1.Font.Size = currentsize - 1;
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            int currentsize = Convert.ToInt32(Label1.Font.Size.ToString().Replace("pt", ""));
            Label1.Font.Size = currentsize + 1;
        }
    }
}

Output : 


Pratik Boghani

Author & Editor

Life is all about the next step.

0 comments:

Post a Comment