Compartir por


WebControl.Width Propiedad

Definición

Obtiene o establece el ancho del control de servidor web.

public:
 virtual property System::Web::UI::WebControls::Unit Width { System::Web::UI::WebControls::Unit get(); void set(System::Web::UI::WebControls::Unit value); };
[System.ComponentModel.Bindable(true)]
public virtual System.Web.UI.WebControls.Unit Width { get; set; }
public virtual System.Web.UI.WebControls.Unit Width { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.Width : System.Web.UI.WebControls.Unit with get, set
member this.Width : System.Web.UI.WebControls.Unit with get, set
Public Overridable Property Width As Unit

Valor de propiedad

Unit que representa el ancho del control. El valor predeterminado es Empty.

Atributos

Excepciones

El ancho del control de servidor web se estableció en un valor negativo.

Ejemplos

En el ejemplo siguiente se muestra cómo establecer mediante declaración la Width propiedad del control, heredada de Table la WebControl clase base.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>WebControl Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>Width Property of a Web Control</h3>
    <asp:Table id="Table1" runat="server"
        CellPadding="10" GridLines="Both"
        Width="350">
 
        <asp:TableRow>
            <asp:TableCell>
                Row 0, Col 0
            </asp:TableCell>
 
            <asp:TableCell>
                Row 0, Col 1
            </asp:TableCell>
        </asp:TableRow>
 
        <asp:TableRow>
            <asp:TableCell>
                Row 1, Col 0
            </asp:TableCell>
 
            <asp:TableCell>
                Row 1, Col 1
            </asp:TableCell>
        </asp:TableRow>
 
 </asp:Table>
 
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head2" runat="server">
    <title>WebControl Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>Width Property of a Web Control</h3>
    <asp:Table id="Table1" runat="server"
        CellPadding="10" GridLines="Both"
        Width="350">
 
        <asp:TableRow>
            <asp:TableCell>
                Row 0, Col 0
            </asp:TableCell>
 
            <asp:TableCell>
                Row 0, Col 1
            </asp:TableCell>
        </asp:TableRow>
 
        <asp:TableRow>
            <asp:TableCell>
                Row 1, Col 0
            </asp:TableCell>
 
            <asp:TableCell>
                Row 1, Col 1
            </asp:TableCell>
        </asp:TableRow>
 
 </asp:Table>
 
    </div>
    </form>
</body>
</html>

Comentarios

Utilice la Width propiedad para especificar el ancho del control de servidor web.

Nota:

Esta propiedad no se representa para todos los controles de exploradores anteriores a la versión 4 de Microsoft Internet Explorer. Los controles que no representan esta propiedad en exploradores anteriores incluyen Label, HyperLink, LinkButtony los controles de validación. RadioButtonList DataList Y CheckBoxListtampoco representan esta propiedad en exploradores anteriores cuando su RepeatLayout propiedad está establecida RepeatLayout.Flowen . Además, solo se admiten tipos de unidad de Pixel y Percentage en exploradores anteriores.

Dado que esta propiedad no es HTML estándar, los controles de servidor web que se muestran como una tabla, como Table y DataGrid, no admiten esta propiedad en exploradores anteriores a la versión 4 de Microsoft Internet Explorer.

Nota:

Para establecer la Width propiedad de forma declarativa en un tipo de unidad distinto del valor predeterminado de , debe crear un nuevo tipo de Pixelunidad específico para el tipo de unidad que desee. Por ejemplo, para establecer la propiedad de Width un control en un valor porcentual de 100, puede hacer lo siguiente:

myWebControl.width = Unit.Percentage(100);

Para obtener más información sobre los tipos de unidad disponibles para la Width propiedad , vea la Unit clase .

Se aplica a

Consulte también