The Textbox control enables the user to enter text. You have the possibility to use the textbox as a single line, multiline or password field by changing the TextMode property. The display width of textbox is determine by its columns property and the height of a textbox is determine by the Row property (only for multiline textmode). You can limit the number of signs the user can enter for a textbox with its textmode set to SingleLine or Password by entering a value for MaxLength.
A very useful event for the textbox control is OnTextChanged. When the cursor focus leaves the textbox this event is triggered. You can use this event to control the input at the very moment the user is done with editing his text.
Label Server Control
The label control display text in a set location on the page. Unlike static text, the Text property of a label can be change programmatically. Layout of the text can be done programmatically by changing properties or with HTML tags(Which are allowed) in the text itself.
Introduction to Server Controls
Every server control has a tag with the runat="server" attribute and is converted to a client specific XHTML.ASP.NET server controls are object and have their own properties method and event handlers. The most useful inherited properties are:
- Controls: gives a collection with all child controls for a specified server control
- EnableViewState: boolean to decide whether the controls has to track his current state or not
- ID: id of the server control,maybe the most important property
- Visible: boolean to decide if the controls will be rendered
- DataBind(): binds the controls with a certain data source (e.g resultset of an sql query)
- FindControl(): searches a child control with the given name(string)
- HasControls(): boolean that define if this server control owns child controls
Validation Controls
Before saving the data entered by the user into a webform, we will have to validate the data. A web form is form which is used to accept data from the user in a web application. We will how to use the validation in a webform to perform the validations against the data entered by the user. Validation controls are controls which help us to perform different validations on the data entered in controls like Textbox, Listbox and radiobutton.
Strings
Strings are supported by the .NET String class. The String data type can represent a series of characters and can contain approximately up to 2 billion Unicode characters. There are many built-in functions in the String class. Some .NET Framework function are also built into the String class. Some common String functions are discussed below:
- LCase: Converts a string to lower case
- UCase:Converts a string to uppercase
- Len: Calculates the number of characters in the string
- LTrim:Omits spaces that appear on the left-side of the string
- RTrim:Omits spaces that appear on the Right-side of the string
- Trim: Omits both leading and trailing spaces
- Clone: Clones a string
- Concat:Joins two strings
- Space: Used to create a string with spaces
- Left: Takes two arguments and return a string that consists of the left most characters of the string sent
- Right: Takes two arguments and return a string that consists of the Right most characters of the string sent
- Instr: Searches and return a shorter string within a long string
- Replace:Searches for a small string in a long string and replace it with the specified string.
Arrays in ASP.NET
Arrays allows you to store a series of value that have the same data type. Each individual value in the array is accessed using one or more index number. It's often convenient to picture arrays as list of data (if the array has more then one dimension) or grids of data (if the array has two dimension). Typically, arrays are laid out contiguously in memory.
All arrays start start at a fixed lower bound. This rule has no exception. When you create an array in C#, you specify the numbers of elements.Because counting start at 0, the highest index is actually one fewer than the number of elements.
//Create an array with four string (from index 0 to index 3).
//You need to initialize the array with the new keyword in order to use it:
string[] vStringArray1=new string[4];
//Create a 2*4 grid array (with a total of 8 integers).
int[,] vIntArray1=new int[2,4];
All arrays start start at a fixed lower bound. This rule has no exception. When you create an array in C#, you specify the numbers of elements.Because counting start at 0, the highest index is actually one fewer than the number of elements.
//Create an array with four string (from index 0 to index 3).
//You need to initialize the array with the new keyword in order to use it:
string[] vStringArray1=new string[4];
//Create a 2*4 grid array (with a total of 8 integers).
int[,] vIntArray1=new int[2,4];
Subscribe to:
Posts (Atom)