Web Controls ASP.NET
Web Controls ASP.NET
2
Web Controls
Initially predicted as future of Internet application development several
years back. It is now already proven by its heavy use.
4
Web Control Tags
<asp:TextBox id=“txt” runat=“server” />
WebControls Namespace
– System.Web.UI.WebConrtrols
5
Web Control Hierarchy
6
WebControl Base Class
AccessKey: keyboard shortcut
BackColor, BorderColor, ForeColor:
BorderWidth: size of control border
BorderStyle: values from enum
Controls: System.Web.UI.Control, Ctype( )
Enabled: If F, control is visible, but doesn’t receive input/ focus.
EnableViewState: auto state mgt
Font: font of any text rendered in the control
Height & Width:
Page:
Parent:
TabIndex: for controlling tab order.
ToolTip: text message displayed when user hovers mouse over control.
Visible: not rendered if F.
7
Four Important Classes
1. Unit
2. Enumerations
3. Color
4. Font
8
Unit
• Unit.Pixel(20)
• Unit.Percentage(50)
• Pnl.Width=Unit.Pixel(300)
9
Enum
This example uses the Enum statement to define a set of named
constants.
In this case, the constants are colors you might choose to design data
entry forms for a database.
10
Public Enum MyColors
Red=“#FF0000”
Green=“#00FF00”
Blue=“#0000FF”
End Enum
11
BorderStyle Enumeration
• Ctrl.BorderStyle=BorderStyle.Dotted
12
Color
• Color.FromARGB(a,r,g,b)
• Color.Yellow
• ColorTranslator.FromHtml(“Blue”)
• System.Drawing namespace
• Ctrl.ForeColor=Color.FromARGB(255,255,255,255)
• Ctrl.ForeColor=Color.Red
• Ctrl.ForeColor=ColorTranslator.FromHtml(“Blue”)
13
Transparency
Alpha measures the transparency of a pixel or image.
14
Font
• Ctrl.Font.Bold=“True”
• Ctrl.Font.Size=FontUnit.Point(14)
15
Focus
• The Focus( ) method effects only input controls that accept
keystrokes from user.
• When the page is rendered in browser the user starts in the focused
control.
• In .aspx
<form id=“Form1” DefaultFocus=“TextBox2” runat=“server”>
• In .vb
Dim ctrl As New TextBox
Me.Form.Controls.Add(ctrl)
ctrl.Focus()
16
Default Button
• <form id=“Form1” DefaultButton=“cmdSubmit” runat=“server”>
• The default button is the button that is clicked when the user
presses the Enter key.
17