Active Server Pages (ASP) and Active Server Pages (ASP.NET) are server-side technologies for displaying interactive web pages.
ASP.NET offers developers a wide range of options in a large, diverse ecosystem of libraries and tools. Developers can also design custom libraries that can be shared with any.NET platform application.
ASP.NET also contains an authentication system for developers, which includes a database, libraries, templates for handling logins, external authentication to Google, Facebook, and other services, and more.
In this article, We will learn about the ASP.NET Web forms and the server controls available in it. We will also different properties and methods available in ASP.NET Server controls.
ASP.NET Server Controls
The built-in ASP.NET server controls in the ASP.NET page framework are designed to provide a more organized programming approach for the Web. The following features are available with these ASP.NET controls:
Automated state management.
Object values can be accessed without using the Request object.
Ability to react to events in the server-side code to construct more structured apps.
The most typical method for creating web page user interfaces.
The output is automatically adjusted based on the browser's capabilities.
The ASP.NET page framework also allows you to construct user controls and custom controls in addition to the built-in elements. Custom controls and user controls can augment and extend current controls, resulting in a far more comprehensive user interface.
Different types of ASP.NET Server Controls
Web forms controls are provided by ASP.NET and are used to construct HTML(Text MarkUp Language) components. These controls are divided into two categories: server-based and client-based. The server controls for web forms are listed in the table below.
Control Name
Applicable Events
Description
TextBox
TextChanged
It's used in the form to generate a text entry.
Label
None
It's used to make text appear on an HTML page.
LinkButton
Click, Command
It's used to make a button that appears to be a hyperlink.
Button
Click, Command
It is used to create a button.
Hyperlink
None
It's used to make a hyperlink control that reacts to a mouse click.
ImageButton
Click
It is used to create an imagesButton. Here, an image works as a Button.
ListBox
SelectedIndexCnhaged
It's used to make a ListBox control that's similar to the HTML control.
DropDownList
SelectedIndexChanged
It's what you'll need to make a dropdown list control.
It indicates whether or not the child controls of the server control have been generated.
Controls
Controls are a collection of all the controls that make up the control.
Context
The server control's linked HttpContext object.
CssClass
CSS(Cascading Style Sheet) class
ControlStyle
The style of the Web server control.
DataKeysContainer
If the naming container implements IDataKeysControl, this method returns a reference to it.
DataItemContainer
If the named container implements IDataItemContainer, this method returns a reference to it.
DisabledCssClass
When the control is disabled, DisabledCssClass gets or sets the CSS class applied to the displayed HTML element.
DesignMode
It specifies whether or not the control is applied to a design surface.
EnableTheming
Indicates whether theming applies to the control.
Enabled
Indicates whether the control is grayed out.
Events
Returns a list of the control's event handler delegates.
EnableViewState
EnableViewState indicates whether the control's view state is preserved.
Forecolor
Foreground colour.
Font
Font.
HasChildViewState
HasChildViewState determines whether the child controls of the current server control have any saved view-state settings.
HasAttributes
Indicates whether the control has attributes set.
ID
Identifier for the control.
Height
Height in pixels or %.
IsEnabled
Returns a value that indicates whether or not the control is active.
IsChildControlStateCleared
IsChildControlStateCleared determines whether or not the controls included within this control have a control state.
IsViewStateEnabled
It specifies whether this control's view state is enabled.
IsTrackingViewState
It specifies whether or not the server control saves changes to its view state.
Page
A page containing the control.
LoadViewStateById
It shows whether the control uses ID instead of an index to load its view state.
RenderingCompatibility
It indicates which version of ASP.NET the rendered HTML will work with.
Parent
Parent control.
SkinID
SkinID is used to get or set the skin that will be applied to the control.
Site
When rendered on a design surface, this is the container that houses the current control.
TabIndex
Gets or sets the Web server control's tab index.
Style
Returns a list of text characteristics that will be presented as a style attribute on the Web server control's outer tag.
TagName
Gets the name of the control tag.
TagKey
The HtmlTextWriterTag value, which corresponds to this Web server control, is returned by TagKey.
TemplateSourceDirectory
The virtual directory of the page or control containing this control is returned by TemplateSourceDirectory.
TemplateControl
The template that contains this control.
UniqueID
Unique identifier.
ToolTip
When the mouse pointer lingers over the webserver control, ToolTip gets or sets the text displayed.
ViewStateIgnoreCase
It tells you if the StateBag object is case-insensitive.
ViewState
Gets a dictionary of state information for saving and restoring a server control's view state across numerous requests for the same page.
Visible
It tells you if a server control is visible or not.
ViewStateMode
Gets or sets the control's view-state mode.
Width
The width of the Web server control is retrieved or set using the Width property.
Methods of ASP.NET Server Controls
The methods of the server controls are listed in the table below.
Method
Description
AddedControl
When a child control is added to the control object's Controls collection, this method is called.
AddAttributesToRender
AddAttributesToRender adds HTML attributes and styles to the specified HtmlTextWriterTag for rendering.
ApplyStyleSheetSkin
ApplyStyleSheetSkin applies the control's style settings from the page style sheet.
AddParsedSubObject
Notifies the server control that an element, either XML or HTML, has been parsed and adds it to the control collection of the server control.
ClearChildControlState
Deletes the server control's child controls' control-state information.
ClearCachedClientID
Infrastructure. Sets the cached ClientID value to null.
ClearChildViewState
Deletes the view-state information for all the server control's child controls.
ClearChildState
Deletes the view-state and control-state information for all the server control's child controls.
CreateControlCollection
Creates a new ControlCollection object to hold the child controls.
CreateChildControls
Used in creating child controls.
DataBind
Binds a data source to the server control and all of its child controls with DataBind.
CreateControlStyle
Creates the style object, which is used to implement all properties related to style.
DataBindChildren
Binds a data source to the child controls of the server control.
DataBind(Boolean)
With the option to raise the DataBinding event, DataBind(Boolean) binds a data source to the server control and all of its child controls.
EnsureChildControls
If the server control has child controls, this value is true. If it doesn't, child controls are created..
Dispose
Dispose of allows a server control to finish cleaning up before being released from memory.
Equals(Object)
Equals(Object) checks whether the specified object and the current object are the same.
EnsureID
EnsureID generates a unique identification for controls that don't have one.
FindControl(String)
FindControl(String) looks for a server control with the supplied id parameter in the current naming container.
Finalize
Allows an object to try to liberate resources and do other cleanup activities before trash collection takes it away.
Focus
Sets input focus to a control.
FindControl(String, Int32)
Searches the ongoing naming container for a server control with the specified id and an integer.
GetType
Gets the type of the current instance.
GetDesignModeState
Gets design-time data for a control.
HasControls
HasControls checks to see if the server control has any children.
GetUniqueIDRelativeTo
GetUniqueIDRelativeTo returns the prefixed component of the provided control's UniqueID property.
IsLiteralContent
IsLiteralContent checks whether the server control only has literal content.
HasEvents
Indicates if the control or any child controls have events registered.
LoadViewState
Restores view-state information.
LoadControlState
Restores control-state information.
MemberwiseClone
Creates a shallow clone of the ongoing object with MemberwiseClone.
MapPathSecure
Returns the physical path to which an absolute or relative virtual path corresponds.
OnBubbleEvent
OnBubbleEvent determines whether the server control's event is transmitted up the UI server control hierarchy on the page.
MergeStyle
MergeStyle copies any non-blank elements of the provided style to the web control, but it does not overwrite any of the control's existing style elements.
OnInit
Raises the Init event.
OnDataBinding
Raises the data binding event.
OnPreRender
Raises the PreRender event.
OnLoad
Raises the Load event.
OpenFile
OpenFile gets a stream that is used to read a file.
OnUnload
Raises the Unload event.
Render
Renders the control to the HTML writer chosen.
RemovedControl
When a child control is deleted from the control object's controls collection, this method is called.
RenderChildren
The contents of the children of a server control are written to a specified HtmlTextWriter object, which renders the contents on the client.
RenderBeginTag
It renders the HTML opening tag of the control of the specified writer.
RenderControl(HtmlTextWriter)
RenderControl(HtmlTextWriter) writes server control content to a HtmlTextWriter object and, if tracing is enabled, stores tracing information about the control.
RenderContents
RenderContents writes the control's contents to the chosen writer.
ResolveAdapter
The control adapter in charge of rendering the specified control is returned.
RenderEndTag
RenderEndTag writes the control's HTML closing tag to the chosen writer.
SaveViewState
SaveViewState saves any changes made to the state since the TrackViewState function was called.
SaveControlState
SaveControlState saves any changes to the server control state that have occurred since the page was last pushed to the server.
ToString
Returns a string that represents the ongoing object when called ToString.
SetDesignModeState
Sets design-time data for a control.
TrackViewState
TrackViewState instructs the control to keep track of changes to its view state so that the object's view state property can be updated.
FAQs
What is ASP.NET? Active Server Pages (ASP) and Active Server Pages (ASP.NET) are server-side technologies for displaying interactive web pages. ASP.NET offers developers a wide range of options in a large, diverse ecosystem of libraries and tools.
What is a web form? Visual Studio comes with ASP.NET Web Forms, which is part of the ASP.NET web application platform. ASP.NET Web Pages, ASP.NET MVC, and ASP.NET Single Page Apps are the other three programming paradigms you can use to construct ASP.NET web applications.
What are ASP.NET server controls of the form? ASP.NET provides web forms controls, which are used to create HTML components. These controls are categorised as server-based and client-based. There are various server controls available for the web forms in ASP.NET such as Label, Checkbox, Text Box, Radio Button, and many more.
How do we handle the submit request from the web form? The handling of the submit request is based on the trigger mechanism of the code behind the file, which triggers when the submit button is clicked on the web forms.
How do we run the user registration form? To run the web form, we just right click and select the view in the browser option in the code editor, to run the user registration form.
Key Takeaways
In this article, We learned about the ASP.NET Web forms and the server controls available in it. We learned about the different types of ASP.NET Server controls. We also learned the properties and methods of the ASP.NET server controls.