Changing width and height of a web control
If you want to set the width and the height of a web control, you can’t just call it like f.e. the text property and give it a certain value in pixels or percentage. This will result in an error. You need to use one of the static functions of the Unit class. You can set the size via pixels or percentage. This works like this:
protected void btnChangeSize_Click(object sender, EventArgs e) { lblResult.Width = Unit.Pixel(100); lblResult.Height = Unit.Percentage(5); lblResult.Text = "Width: " + lblResult.Width + ", Height: " + lblResult.Height; }