asp.net - How to change FileUpload width programmatically

FileUpload Width
FileUpload is an asp.net web server control. FileUpload control display a textbox control and a browse button that enable users to select a file from their computer file system and upload it to web server.

FileUpload control's Width property allow us to get or set the width of the FileUpload control. the Width property value type is System.Web.UI.WebControls.Unit. this Unit represents the width of the FileUpload control. Width property default value is Empty.

FileUpload control's Width property throw ArgumentException exception, if the Width is set to a negative value.

the following asp.net c# example code demonstrate us how can we set or change FileUpload server control's width programmatically at run time in an asp.net application.
FileUploadWidth.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        FileUpload1.Width = 250;

    }
    protected void Button2_Click(object sender, System.EventArgs e)
    {
        FileUpload1.Width = 400;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to set, change FileUpload width programmatically</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy; font-style:italic;">FileUpload Example: Change Width</h2>
        <div style="height:150px">
            <asp:FileUpload 
                 ID="FileUpload1" 
                 runat="server"
                 ForeColor="Wheat"
                 BackColor="Tomato"
                 Font-Size="Large"
                 />
        </div>
        <asp:Button 
             ID="Button1" 
             runat="server"
             ForeColor="Navy"
             Text="FileUpload Width 250"
             Height="45"
             OnClick="Button1_Click"
             Font-Bold="true"
             />
        <asp:Button 
             ID="Button2" 
             runat="server"
             ForeColor="Navy"
             Text="FileUpload Width 400"
             Height="45"
             OnClick="Button2_Click"
             Font-Bold="true"
             />
    </div>
    </form>
</body>
</html>
More asp.net examples