JavaScript Editor jscript editor     Web designer 



Main Page

If a Web server control property's data type is a primitive type, such as a String, Boolean, or numeric type, you can set the property value by simply assigning it to the property. Similarly, if the property's values are defined in an enumeration class, you can simply assign the enumeration to the property.

To set a property value based on simple values

  • Assign the value as a literal or variable, as in the following example:

    Visual BasicВ CopyCode imageCopy Code
    Label1.Text = "Hello"
    Datagrid1.PageSize = 5
    
    C#В CopyCode imageCopy Code
    Label1.Text = "Hello";
    DataGrid1.PageSize = 5;
    

To set a property value based on an enumeration

  • Assign the value using one of the enumeration values. ASP.NET can resolve the enumeration based on the property's type. The following code example illustrates setting a property using an enumeration:

    Visual BasicВ CopyCode imageCopy Code
    'Uses TextBoxMode enumeration
    TextBox1.TextMode = TextBoxMode.SingleLine
    'Uses ImageAlign enumeration
    Image1.ImageAlign = ImageAlign.Middle
    
    C#В CopyCode imageCopy Code
    // Uses TextBoxMode enumeration 
    TextBox1.TextMode = TextBoxMode.SingleLine;
    // Uses ImageAlign enumeration
    Image1.ImageAlign = ImageAlign.Middle;
    

See Also

Tasks

How to: Set HTML Server Control Properties Programmatically

Other Resources

Setting Web Server Control Properties Programmatically (Visual Studio)



JavaScript Editor jscript editor     Web designer