February 23, 2009

The following shows how to apply properties to a Asp.Net TextBox web server control programmatically.

The id of the textbox control is "TextBox1".
TextBox1.AccessKey = "k"; //set accesskey
TextBox1.AutoPostBack = true; //set if autoPostBack is true

TextBox1.BackColor = System.Drawing.Color.Yellow; //set background color
TextBox1.BorderColor = System.Drawing.Color.Black; //set border color
TextBox1.ForeColor = System.Drawing.Color.Green; //set color

TextBox1.BorderStyle = BorderStyle.Dotted; //set border style
TextBox1.BorderWidth = 1; //set border width

TextBox1.Columns = 20; //set no of columns
TextBox1.CssClass = "someClass"; //apply css class
TextBox1.Enabled = true; //set if enabled

TextBox1.EnableViewState = true; //set if viewstate is true


TextBox1.Height = 50; //set height

TextBox1.MaxLength = 15;
TextBox1.ReadOnly = false; //set if readonly
TextBox1.Rows = 2; //set no of rows
TextBox1.TabIndex = 2; // set tabindex
TextBox1.Text = "default"; //set default text
TextBox1.TextMode = TextBoxMode.MultiLine; //set if textfield or textarea
TextBox1.ToolTip = "tip"; //set tootip
TextBox1.Visible = true; //set if visible
TextBox1.Width = 180; //set width
TextBox1.Wrap = true; //set if text appears wrapped

1 comments:

md parvez said...

It is a one of the great discussion which is very informative to me as well. I am sure the discussion will be essential for me as well. Keep it up.
Kallis

Reference: Shahed Kazi at AspNetify.com