Training
Module
Use and understand Controls in a canvas app in Power Apps - Training
Controls help create a better experience for the user and collect the appropriate data. This module helps you understand and use Controls.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This article introduces ASP.NET server controls, such as HTML server controls, Web server controls, List controls etc.
Original product version: ASP.NET
Original KB number: 306459
This article refers to the following Microsoft .NET Framework Class Library namespaces:
System.Web.UI.HtmlControls.HtmlControl
System.Web.UI.WebControls.WebControl
The ASP.NET page framework includes a number of built-in server controls that are designed to provide a more structured programming model for the Web. These controls provide the following features:
Request
object.In addition to the built-in controls, the ASP.NET page framework also provides the ability to create user controls and custom controls. User controls and custom controls can enhance and extend existing controls to build a much richer user interface.
The HTML server controls are HTML elements that include a runat=server
attribute. The HTML server controls have the same HTML output and the same properties as their corresponding HTML tags. In addition, HTML server controls provide automatic state management and server-side events. HTML server controls offer the following advantages:
runat=server
attribute are compiled into the assembly.OnServerEvent
for the most commonly used event for the control. For example, the <input type=button>
control has an OnServerClick
event.HtmlGenericControl
.The System.Web.UI.HtmlControls.HtmlControl
base class contains all of the common properties. HTML server controls derive from this class.
To use an HTML server control, use the following syntax (which uses the HtmlInputText
control as an example):
<input type="text" value="hello world" runat=server />
For more information about individual HTML server controls that are available in ASP.NET, see the following Web sites:
Web controls are similar to the HTML server controls such as Button, TextBox, and Hyperlink, except that Web controls have a standardized set of property names. Web server controls offer the following advantages:
The System.Web.UI.WebControls.WebControl
base class contains all of the common properties. Most of the Web server controls derive from this class.
To use a Web server control, use the following syntax (which uses the TextBox control as an example):
<asp:textbox text="hello world" runat=server />
Web server controls can be divided into four categories:
Basic Web controls provide the same functionality as their HTML server control counterparts. However, basic Web controls include additional methods, events, and properties against which you can program.
For more information about individual Web controls that are available in ASP.NET, see the following Web sites:
Validation controls are used to validate the values that are entered into other controls of the page. Validation controls perform client-side validation, server-side validation, or both, depending on the capabilities of the browser in which the page is displayed. Validation controls offer the following advantages:
Note
A client-side validation catches errors before a postback operation is complete. Therefore, if you have combinations of client-side and server-side validation controls on a single page, the server-side validation will be preempted if a client-side validation fails.For more information about individual validation controls that are available in ASP.NET, refer to the following Web sites:
List controls are special Web server controls that support binding to collections. You can use list controls to display rows of data in a customized, template's format. All list controls expose DataSource and DataMember properties, which are used to bind to collections.
List controls can bind only to collections that support the IEnumerable, ICollection, or IListSource interfaces. For example, a Visual C# .NET sample page appears as follows:
<%@ Page Language="C#" %>
<script runat="server">
Public void Page_Load()
{
String[] myStringArray = new String[] {"one","two","three"};
rptr.DataSource = myStringArray;
rptr.DataBind();
}
</script>
<html>
<body>
<asp:repeater id=rptr runat="server">
<itemtemplate><%# Container.DataItem %><br></itemtemplate>
</asp:repeater>
</body>
</html>
A Visual Basic .NET sample page appears as follows:
<%@ Page Language="vb" %>
<script runat="server">
public sub Page_Load()
Dim myStringArray as String()
myStringArray = new String() {"one","two","three"}
rptr.DataSource = myStringArray
rptr.DataBind()
end sub
</script>
<html>
<body>
<asp:repeater id=rptr runat="server">
<itemtemplate><%# Container.DataItem %><br></itemtemplate>
</asp:repeater>
</body>
</html>
The output appears as follows:
For more information about individual list controls that are available in ASP.NET, see the following Web sites:
In addition to the preceding controls, the ASP.NET page framework provides a few, task-specific controls called rich controls. Rich controls are built with multiple HTML elements and contain rich functionality. Examples of rich controls are the Calendar control and the AdRotator control.
For more information about individual rich controls that are available in ASP.NET, see the following Web sites:
Often, you may want to reuse the user interface of your Web Form without having to write any extra code. ASP.NET enables you to do this by converting your Web Forms into user controls. User controls, which have the.ascx file extension, can be used multiple times within a single Web Form.
To convert a Web Form into a user control, follow these steps:
<html>
, <head>
, <body>
, and <form>
tags.@ Page
directive appears in the page, change it to @ Control
.className
attribute in the @ Control
directive so that the user control is typed strongly when you instantiate it.For more information about user controls, see Web Forms User Controls.
In addition to the built-in Web controls, ASP.NET also allows you to create your own custom controls. It may be useful to develop custom controls if you are faced with one of these scenarios:
For more information about developing custom controls, see the following topics:
Training
Module
Use and understand Controls in a canvas app in Power Apps - Training
Controls help create a better experience for the user and collect the appropriate data. This module helps you understand and use Controls.