ASP.NET Server Controls Explained – Button, TextBox, GridView | BCA Sem 5

BCA Sem 5  |  Unit 1  |  ASP.NET



Types of Controls in ASP.NET

Buttons, textboxes, dropdowns & more — the building blocks of every web form

BKNMU Junagadh NEP 2020 Web Forms Server Controls
In simple words: Controls are the building blocks of an ASP.NET web page — things like buttons, textboxes, checkboxes, and dropdowns. Instead of writing plain HTML, ASP.NET gives you ready-made "smart" controls that run code on the server and remember their values automatically.
📖 What are Controls in ASP.NET?

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.

📦 Four Main Categories of Controls

🟪 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.

ℹ️ Most Used in Practice: Web Server Controls are what you'll use 90% of the time in ASP.NET Web Forms — they are powerful, have rich properties, and automatically maintain ViewState.
🎨 Standard Controls — Visual Showcase
<asp:Button> Triggers a postback or runs a server-side action on click.
Submit
<asp:TextBox> Lets users type and submit text input.
<asp:CheckBox> A simple true/false toggle option.
I agree to terms
<asp:Label> Displays read-only text, often updated dynamically.
Welcome, Student!
<asp:Panel> A container to group and show/hide multiple controls together.
Panel Container (groups controls)
<asp:ListBox> Shows a scrollable list where users can select one or more items.
<asp:DropDownList> A collapsible dropdown for choosing a single option.
<asp:FileUpload> Allows users to select and upload a file to the server.
📎 Choose File — no file selected
<asp:AdRotator> Displays rotating banner advertisements from an XML file.
🖼️ Ad Banner #1 of N (rotates)
<asp:CheckBoxList> A group of checkboxes generated from a data source.
HTML
CSS
ASP.NET
<asp:RadioButtonList> Lets the user pick exactly one choice from a group.
<asp:ImageMap> An image with multiple clickable regions, each posting back separately.
🗺️ Clickable Image Regions
<asp:Wizard> Breaks a long form into multiple steps with Next/Back navigation.
Step 1 ● → Step 2 ○ → Step 3 ○
<asp:Calendar> A full month calendar control to select dates easily.
S
M
T
W
T
F
S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<asp:GridView> Displays tabular data — most used control for showing database records.
IDName
1Raj
2Asha
✅ What is Validation? (Quick Intro)

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.

ValidatorWhat It Checks
RequiredFieldValidatorEnsures the field is not left empty
RangeValidatorChecks if value falls within a min-max range
CompareFieldValidatorCompares two fields (e.g. Password & Confirm Password)
RegularExpressionValidatorChecks input against a pattern (e.g. valid email format)
CustomValidatorRuns your own custom validation logic
ValidationSummaryShows a summary list of all validation errors on the page
💻 Code Example — Using Controls Together
<asp:TextBox ID="txtEmail" runat="server" /> <asp:RequiredFieldValidator runat="server" ControlToValidate="txtEmail" ErrorMessage="Email is required!" /> <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
💡 Tip: Every Web Server Control must have runat="server" — without it, ASP.NET treats it as plain HTML and you can't access it from your C# code-behind!
📝 Quick Revision — Key Points for Exam
  • 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.

Post a Comment

Thanks for comment.

Previous Post Next Post