Why do I get the result zero when I try to get the width of a DropDownList control in asp.net?

Posted by Paul Jack on Programmers See other posts from Programmers or by Paul Jack
Published on 2011-03-01T06:43:52Z Indexed on 2011/03/01 7:31 UTC
Read the original article Hit count: 305

Filed under:

After I click button1, it display 0, why? How can get correct width of a DropDownList control? Thanks!

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>


Item 1 Item 2

</div>
</form>

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();
}

}

© Programmers or respective owner

Related posts about ASP.NET