Why do I get the result zero when I try to get the width of a DropDownList control in asp.net?
<p>After I click button1, it display 0, why?  How can get correct width of a DropDownList control? Thanks!</p>

<pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head runat="server"&gt;
    &lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form id="form1" runat="server"&gt;
    &lt;div&gt;    
        &lt;asp:Button ID="Button1" runat="server" Text="Button" /&gt;
        &lt;asp:DropDownList ID="DropDownList1" runat="server"&gt;
            &lt;asp:ListItem&gt;Item 1&lt;/asp:ListItem&gt;
            &lt;asp:ListItem&gt;Item 2&lt;/asp:ListItem&gt;
        &lt;/asp:DropDownList&gt;
    &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p><br></p>

<pre><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 Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        Button1.Text = DropDownList1.Width.Value.ToString();
    }
}
</code></pre>
