-->

Friday, October 23, 2015

ASP.NET FILEUPLOAD CONTROL CHANGE BACKGROUND COLOR USING CODE

ASP.NET FILEUPLOAD CONTROL CHANGE BACKGROUND COLOR USING CODE

Each control in ASP.NET ToolBox of visual studio, treat as a class. Property window shows the behavior of their controls also contains some common property, such as back-color, border color etc. Now in this article, we will take a simple example to change the background color of ASP.NET file upload control.

Description
I explained, ASP.NET FILEUPLOAD CONTROL change border color, File upload control enable/disable

Source code




 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="fileupload_backcolor.aspx.cs" Inherits="fileupload_backcolor" %>  
 <!DOCTYPE html>  
 <html xmlns="http://www.w3.org/1999/xhtml">  
 <head runat="server">  
   <title></title>  
 </head>  
 <body>  
   <form id="form1" runat="server">  
   <div>  
     Enter Alpha color :  
     <asp:TextBox ID="TextBox1" runat="server" Width="202px"></asp:TextBox>  
     <br />  
     Enter Red Color :  
     <asp:TextBox ID="TextBox2" runat="server" Width="202px"></asp:TextBox>  
     <br />  
     Enter Green Color:  
     <asp:TextBox ID="TextBox3" runat="server" Width="202px"></asp:TextBox>  
     <br />  
     Enter Blue Color&nbsp;&nbsp; :  
     <asp:TextBox ID="TextBox4" runat="server" Width="202px"></asp:TextBox>  
     <br />  
     <br />  
     <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Change Fileupload background color" Width="260px" />  
     <br />  
     <br />  
   </div>  
     <asp:FileUpload ID="FileUpload1" runat="server" Height="51px" Width="311px" />  
   </form>  
 </body>  
 </html>  

Code Behind Code

 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Web;  
 using System.Web.UI;  
 using System.Web.UI.WebControls;  
 public partial class fileupload_backcolor : System.Web.UI.Page  
 {  
   protected void Page_Load(object sender, EventArgs e)  
   {  
   }  
   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);  
     FileUpload1.BackColor = System.Drawing.Color.FromArgb(alpha, red, green, blue);  
   }  
 }  

Code Generate the following output

programmatically change background color of fileupload control in ASP.NET

programmatically change background color of fileupload control in ASP.NET

In this example, we are taking four textboxes, one button, one file upload control. Using text box we can input the color code value and pass these values into the FromArgb ( ) method. This example is basically designed for users, who want to change the color of file upload control at run time.

Read other related articles

Also read other articles

© Copyright 2013 Computer Programming | All Right Reserved