How to change text (Font) size on Button click in ASP.Net C#

Source Code

<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="lbout" runat="server" Text="Welcome in Code Solution" Font-Size="12"></asp:Label>
        <br />
        <br />
        <br />
        <asp:Button ID="btnincrease" runat="server" Text="+"
            onclick="btnincrease_Click" />
        &nbsp;
        &nbsp;<asp:Button ID="btndecrease" runat="server" Text="-"
            onclick="btndecrease_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;

public partial class fontsizelabel : System.Web.UI.Page
{
   
    protected void Page_Load(object sender, EventArgs e)
    {

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

    }
    protected void btndecrease_Click(object sender, EventArgs e)
    {
        int currentSize = Convert.ToInt32(lbout.Font.Size.ToString().Replace("pt", ""));
        lbout.Font.Size = currentSize - 1;
    }
}


Out- Put


How to change text (Font) size on Button click in ASP.Net C# How to change text (Font) size on Button click  in ASP.Net C# Reviewed by NEERAJ SRIVASTAVA on 10:49:00 PM Rating: 5

No comments:

Powered by Blogger.