Search

Thursday, July 17, 2014
0 comments

How to change text color from ARGB value in ASP.NET

11:54 PMThursday, July 17, 2014
ARGB( ) takes four integer input parameter as a argument. Method name explain all things automatically. This name contain four color code, first "A" for Alpha which take 0-255 integer value. Similarly "R" for RED , "G" for Green and "B" for blue. Now lets take an simple example of ARGB( ) method.

How to change text color from ARGB value in ASP.NETSource code

<form id="form1" runat="server">
    <div>
    
        Enter Alpha Color code :
        <asp:TextBox ID="TextBox1" runat="server" Width="190px"></asp:TextBox>
        <br />
        Enter Red Color Code&nbsp;&nbsp;&nbsp; :<asp:TextBox ID="TextBox2" runat="server" Width="190px"></asp:TextBox>
        <br />
        Enter Green Color Code:<asp:TextBox ID="TextBox3" runat="server" Width="190px"></asp:TextBox>
        <br />
        Enter Blue Color Code&nbsp;&nbsp; :
        <asp:TextBox ID="TextBox4" runat="server" Width="190px"></asp:TextBox>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Click to change " Width="95px" />
        <br />
    
    </div>
        <asp:Label ID="Label1" runat="server" Font-Size="20pt" Text="Result Label "></asp:Label>
    </form>

CodeBehind Code



protected void Button1_Click(object sender, EventArgs e)
    {
       
        int alpha = int.Parse (TextBox1.Text);
        int red = int.Parse (TextBox2.Text);
        int green = int.Parse (TextBox3.Text);
        int blue =int.Parse ( TextBox4.Text);
        Label1.ForeColor = System.Drawing.Color.FromArgb(alpha, red, green, blue);


    }   

Code generate the following output


How to change text color from ARGB value in ASP.NET
Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top