Web Forms Server Controls Controls You Can Use on Web Forms ASP.NET IE Web Controls
This article provides general information on authoring Web Forms with the Microsoft Internet Explorer WebControls. The information given here is applicable equally to authoring with the MultiPage, TabStrip, Toolbar, and TreeView controls.
When authoring Web Forms pages using the IE WebControls, it is necessary to include certain processing directives to keep the resulting Extensible Markup Language (XML) content concise and enable ASP.NET scripts to access the WebControls namespace and its associated objects.
Two processing directives are added to an ASP.NET Web Forms page to enable WebControls to be authored and scripted on the page.
The @ Import directive allows an author to write code that refers to the Microsoft.Web.UI.WebControls namespace from within the .aspx page.
<%@ Import namespace="Microsoft.Web.UI.WebControls" %>
This directive is required when writing Web Forms that use server-side script to create or modify WebControls objects. If this statement is not included in the .aspx file, it is not possible to generate WebControls elements dynamically.
The @ Register directive is used to associate a user-defined tag prefix with an assembly and its namespace. When authoring with an element that has been implemented with a custom control, for example TabStrip, the namespace of the assembly is specified as the tag prefix of the element.
In many cases the name of a namespace can be lengthy, so it is both practical and convenient to associate a short tag prefix with the namespace, and use this in the code and markup.
<%@ Register tagprefix="ie" namespace="Microsoft.Web.UI.WebControls"
assembly="Microsoft.Web.UI.WebControls" %>
These directives should be placed at the top of the Web Form page, before any of the WebControls elements are used or referenced.
After the @ Import and @ Register directives have been declared, the WebControls elements can be authored declaratively or programmatically.
All HTML markup for WebControls must reside within a containing <form
> control with the runat="server" attribute/value pair.
<form runat="server">
... WebControls markup goes here ...
</form>
All WebControls markup also requires runat="server" on the top-level element of the control, but this attribute is not required on the child elements. For example, a MultiPage requires runat="server", whereas PageView elements do not.
The AutoPostBack attribute is used to control how the client browser posts user interactions to the server. When AutoPostBack is true, every interaction with the control causes a postback, and the server controls are used to update the page rendering.
When AutoPostBack is false, the controls never cause a postback. Therefore, by setting AutoPostBack to false, it is possible to handle the events fired on the client-side behavior and force a postback with DHTML.
As a general rule, when posting forms with the WebControls, it is useful to test the IsPostBack property in the Page_Load event before creating controls or manipulating them with script. Controls only need to be created once and are persisted for each postback to the server. The first time a page is loaded, there is no postback; this condition provides a convenient way to determine if the Web Form has been initialized.
<script language="C#" runat="server">
public void Page_Load ( Object sender, EventArgs e ) {
if ( ! IsPostBack ) {
SetupButtons ( );
}
}
</script>
Internet Explorer WebControls Overview Internet Explorer WebControls Prerequisites