Unit 2
Unit 2
HTML Control
HTML controls are the standard HTML elements that are interpreted by the browser. They
include elements like <input>, <button>, <select>, <text area>, etc.
Characteristics:
Standard HTML: They are pure HTML elements.
No Server-Side Processing: They do not have built-in server-side processing capabilities.
Static: They do not maintain any state information between postbacks.
Client-Side: They are primarily used for client-side processing and validation.
ID Attributes: HTML controls are accessed via their id attributes using JavaScript or jQuery.
Example
<input type="text" id="txtName" />
<input type="text">
Example
Password Input
<input type="password">
Ex.
Button
<input type="button">,
<input type="submit">
EX.
Checkbox
<input type="checkbox">
Ex.
<input type="checkbox" id="chkAgree" name="chkAgree" />
Radio Button
<input type="radio">
Ex.
Dropdown List
<Select>
Server Controls
Server controls are ASP.NET controls that are processed on the server side. They are derived
from the System.Web.UI.Control class and provide more functionality than standard HTML
controls.
Characteristics:
ASP.NET Specific: They are specifically designed for ASP.NET web applications.
Server-Side Processing: They can handle server-side events and have built-in event handlers.
Runat="server": They must include the runat="server" attribute to be processed on the server
side.
Automatic ID Generation: ASP.NET automatically manages the control's ID, which can be
accessed using ControlName.ClientID.
Example:
<asp:TextBox ID="txtName" runat="server" />
Property Description
Property Description
Property Description
Calendar control
MultiView control
Wizard control
AdRotator control
Property Description
Calendar control
Calendar control provides you lots of property and events. By using these properties and events
you can perform the following task with calendar control.
Select date., Selecting a day, a week or a month, Customize the calendar's appearance.
The Calendar control supports three important events:
Event Description
SelectionChanged This event is fired when you select a day, a week or an entire month.
DayRender This event is fired when each data cell of the calendar control is
rendered.
Calendar control supports SelectionMode property that allows you to select a single day, week,
or entire month.
MultiView control
MultiView control can be used when you want to create a tabbed page. In many situations, a web
form may be very long, and then you can divide a long form into multiple sub forms. MultiView
control is made up of multiple view controls. You can put multiple ASP.NET controls inside
view controls. One View control is displayed at a time and it is called as the active view. View
control does not work separately. It is always used with a Multiview control.
If working with Visual Studio 2010 or later, you can drag and drop a MultiView control onto the
form. You can drag and drop any number of View controls inside the MultiView control. The
number of view controls is depends upon the need of your application.
Wizard Control
This control is same as MultiView control but the main difference is that, it has inbuilt
navigation buttons.
The wizard control enables you to design a long form in such a way that you can work in
multiple sub form. You can perform the task in a step by step process. It reduces the work of
developers to design multiple forms. It enables you to create multi step user interface. Wizard
control provides with built-in previous/nextfunctionality.
The Wizard control can contains one or more WizardStep as child controls. Only one
WizardStep is displayed at a time. WizardStep control has an important property called as
StepType. The StepType property determines the type of navigation buttons that will be
displayed for that step.
The possible values are:
The StepType associated with each WizardStep determines the type of navigation buttons that
will be displayed for that step. The StepTypes are:
Start:
Step:
Finish:
Complete:
Auto:
Drag the Wizard control on the web page from toolbox, you will get the following code.
AdRotator control
AdRotator control is used to display different advertisements randomly in a page. The list of
advertisements is stored in either an XML file or in a database table. Lots of websites uses
AdRotator control to display the advertisements on the web page.
Important properties of AdRotator control.
ImageUrl: The URL of the image that will be displayed through AdRotator control.
NavigateUrl: If the user clicks the banner or ad then the new page is opened according to given
URL.
AlternateText: It is used for displaying text instead of the picture if picture is not displayed. It is
also used as a tooltip.
Impressions: It is a number that sets how frequently an advertisement will appear.
Keyword: It is used to filter ads or identifies a group of advertisement.
Validation Controls
BaseValidator Class
The validation control classes are inherited from the BaseValidator class hence they inherit its
properties and methods. Therefore, it would help to take a look at the properties and the methods
of this base class, which are common for all the validation controls:
Members Description
SetFocusOnError It indicates whether in case of an invalid control, the focus should switch to
the related input control.
ValidationGroup The logical group of multiple validators, where this control belongs.
Validate() This method revalidates the control and updates the IsValid property.
To perform validation, ASP.NET provides controls that automatically check user input and
require no code. We can also create custom validation for our application.
Validator Description
Property Description
Property Description
Property Description
ErrorMessage It is used to set error message that display when validation fails.
Property Description
ErrorMessage It is used to set error message that display when validation fails.
Property Description
AccessKey It is used to set keyboard shortcut for the control.
ShowValidationErrors It is used to set whether the validation summary should be shown or not.
CustomValidator
The CustomValidator control allows writing application specific custom validation
routines for both the client side and the server side validation.
The client side validation is accomplished through the ClientValidationFunction property.
The client side validation routine should be written in a scripting language, such as
JavaScript or VBScript, which the browser can understand.
The server side validation routine must be called from the control's ServerValidate event
handler. The server side validation routine should be written in any .Net language, like
C# or VB.Net.
The basic syntax for the control is as given:
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction=.cvf_func. ErrorMessage="CustomValidator">
</asp:CustomValidator>