BCA Sem 5 | Unit 1 | ASP.NET
Types of Controls in ASP.NET
Buttons, textboxes, dropdowns & more — the building blocks of every web form
A control is simply a UI element you place on a web page — like a textbox to type your name, or a button to submit a form. In ASP.NET, these controls are written using <asp:ControlName> tags and have the special attribute runat="server", which tells ASP.NET to process them on the server, not just the browser.
🟪 HTML Controls
Plain HTML elements without runat="server". Processed only by the browser, not the server.
🟦 HTML Server Controls
HTML elements with runat="server" added — now ASP.NET can access them in code-behind.
🟩 Web Server Controls
ASP.NET's own rich controls like <asp:Button>, <asp:GridView> — most commonly used.
🟧 Validation Controls
Special controls that check user input — like RequiredFieldValidator, RangeValidator.
| ID | Name |
|---|---|
| 1 | Raj |
| 2 | Asha |
Validation means checking whether user input is correct before processing it — for example, making sure an email field isn't empty, or a number is within range. ASP.NET makes this easy with built-in Validation Controls.
🌐 Client-Side Validation
Checked instantly in the browser using JavaScript — fast, no server round-trip needed.
🖧 Server-Side Validation
Checked on the server after submission — more secure, can't be bypassed by disabling JS.
| Validator | What It Checks |
|---|---|
RequiredFieldValidator | Ensures the field is not left empty |
RangeValidator | Checks if value falls within a min-max range |
CompareFieldValidator | Compares two fields (e.g. Password & Confirm Password) |
RegularExpressionValidator | Checks input against a pattern (e.g. valid email format) |
CustomValidator | Runs your own custom validation logic |
ValidationSummary | Shows a summary list of all validation errors on the page |
runat="server" — without it, ASP.NET treats it as plain HTML and you can't access it from your C# code-behind!
- Controls = UI building blocks of an ASP.NET page (buttons, textboxes, etc.).
- 4 categories: HTML Controls, HTML Server Controls, Web Server Controls, Validation Controls.
- runat="server" is required for any control to be processed on the server.
- Common controls: Button, TextBox, CheckBox, Label, Panel, ListBox, DropDownList.
- Special controls: FileUpload, AdRotator, CheckBoxList, RadioButtonList, ImageMap, Wizard, Calendar.
- Validation = checking user input before processing it.
- Client-side validation runs in browser (JS) — Server-side runs on server (secure).
- 6 main validators: RequiredField, Range, CompareField, RegularExpression, Custom, ValidationSummary.
