Each control in tools 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 border color with border style of ASP.NET FILEUPLOAD control. I explained, How to use file upload, enable/disable file upload and many more properties.
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 :
<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
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.BorderColor = System.Drawing.Color.FromArgb(alpha, red, green, blue);
FileUpload1.BorderStyle = BorderStyle.Solid;
FileUpload1.BorderWidth = 2;
}
}
Code Generates the following output
In this example, we are taking four textboxes, one button, one file upload control. Using text box we can input the color code value, pass these values in the FromArgb ( ) method as an argument. This example is basically designed for users, who want to change the border color of ASP.NET FILEUPLOAD control at run time.