Code Generation Tags

Code generation tags instruct Iron Speed Designer what databound controls to create.  Code generation tags specify the database-connected tables, fields, filters, and other controls you want in your application.  They are stored in the Layout Editor and you can wrap them in additional text, HTML, and ASP.NET controls via the HTML Editor.  When you drag a control from the Toolbox onto your page in Layout Editor, you are very often adding a code generation tag.

Code generation tags instruct Iron Speed Designer which components to create.

This example shows how complex pages are constructed from with code generation tags in the Layout Editor.

When you build your application, Iron Speed Designer replaces the code generation tags with ASP.NET controls to produce ready-to-run ASPX pages.  The code generation tags are stripped replaced by corresponding web controls, code-behind logic, and transaction management code.  This also means that the code generation tags have no run-time effect on your application because they are not present in the application.

Most individual databound controls represented by code generation tags are bound to underlying data sources.  A control is bound by specifying the databases, tables, and fields to be connected to the component via the Property Sheet.  Iron Speed Designer uses component properties and table schemas to create your application’s code and user interface.

 

Individual components on the page, represented by code generation tags, are bound to the underlying database tables and fields.  This allows Iron Speed Designer to create specific code and SQL queries corresponding to the underlying database tables.

Each different code generation tag in Iron Speed Designer has its own set of properties because different components have different parameters.  For example, an Image control (Image code generation tag) is set to the URL, file name, or database field containing the image to be displayed.  In contrast, a Table control (Table code generation tag) is bound to the underlying database table or multi-table join to be displayed, along with the specific columns to be displayed, their order, etc.  You have control over virtually every aspect of that component’s behavior via the Property Sheet.

 

 

Types of code generation tags

The code generation tags are divided into these groups:

Field Display Tags

Record Tags

Table Tags

Table Component Tags

FieldLabel
FieldValue

Record

Table

FieldStatistics
Pagination
TableStatistics

Filter Tags

Layout Tags

Button Tags

Grouping Tags

FieldFilter
SearchFilter

HTML
HyperLink
Image
Label
Literal
Text

ImageButton
LinkButton
PushButton

Group
Menu
TabContainer
TabPanel
Use

The specifics of each individual code generation tag are discussed elsewhere in more detail.

How code generation tags work

Iron Speed Designer’s Application Wizard inserts code generation tags into the Layout Editor at locations where databound controls will be placed.  Use the Property Sheet to specify various data display settings and other properties.  Iron Speed Designer uses these properties to create the page component specified by each code generation tag.

You don’t have to learn how to program SQL.  Unlike many scripting languages, code generation tags aren’t SQL queries, so you don’t need learn the SQL language.  Iron Speed Designer creates all of the SQL queries for you, using the information gathered about each of the code generation tags, generally from your direct input in Iron Speed Designer.  

The code generation tags will be replaced with one or more ASP.NET control tags in the ASPX or ASCX files created by Iron Speed Designer.  For example, a GEN:IMAGEBUTTON tag is replaced with ASP.NET control tags to support an action that will be taken when the button is pressed.

Code Generation tag:

<GEN:ImageButton Name=“PlaceOrder”/>

ASP.NET control tag:

<BaseClasses:ImageButton runat="server" id="MyImageButton" CausesValidation="True"

              CommandName="Redirect"

              Consumers="None"

              ImageURL="/images/PlaceOrder.gif"

              RedirectURL="/Pages/ConfirmOrder.aspx"

              ToolTip="Press this button to place your order.">

</BaseClasses:ImageButton>

Some code generation tags specify complex layout and functionality.  For example, a GEN:FieldValue tag is used for editing a database field value.  Iron Speed Designer automatically replaces this tag with an ASP.NET text box control and several controls that specify the validation that is required for this field.  For example, the field may be a required field where a RequiredFieldValidator is also created.  In this case, the number of ASP.NET control tags created would be more than one tag to replace one code generation tag.

Code Generation tag:

<GEN:FieldValue Name=“LastName” />

ASP.NET control tags:

<BaseClasses:FieldValueTextBox runat="server" id="LastName"

              Field="LastName" Columns="25" CssClass="field_input">

</BaseClasses:FieldValueTextBox>

 

<BaseClasses:RequiredFieldValidator runat="server" id="LastNameRequiredFieldValidator"

              ControlToValidate="LastName" Enabled="False" ErrorMessage="LastName value is required.">

</BaseClasses:RequiredFieldValidator>

 

<BaseClasses:TextBoxMaxLengthValidator runat="server" id="LastNameTextBoxMaxLengthValidator"

              ControlToValidate="LastName" ErrorMessage="Value for LastName is too long.">

</BaseClasses:TextBoxMaxLengthValidator>

 

<BaseClasses:FieldValueValidator runat="server" id="LastNameFieldValueValidator"

              ControlToValidate="LastName" ErrorMessage="Invalid value for LastName.">

</BaseClasses:FieldValueValidator>

 

<BaseClasses:RecordControlCustomValidator runat="server"

              id="LastNameRecordControlCustomValidator"

              ControlToValidate="LastName" ErrorMessage="Invalid value for LastName.">

</BaseClasses:RecordControlCustomValidator>

Code generation tags that are not bound to valid data sources are ignored when updating ASPX pages and ASCX controls.

Code generation tag syntax

Code generation tags are based on XML and contain a tag prefix to differentiate them from identically named XML-based tags that you might use.  For example, the HTML <BUTTON> tag must be differentiated from the BUTTON code generation tag because they mean two completely different things.  To differentiate the code generation tag, we use the code generation tag prefix and specify this tag as <GEN:Button>.  The Tag Prefix is also called the XML Namespace.

The tag prefix immediate follows the “<“ or “</” in a tag and ends with “:”.  For code generation tags, the tag prefix is “GEN”.  For example, to place a simple button on a page, use:

<GEN:Button Name=“EditCustomer”/>

The basic rules of syntax for code generation tags are similar to all other XML-based markup languages:

Code generation tags can be specified in either of two XML formats show below:

<GEN:Button Name=“EditCustomer”/>

<GEN:Button Name=“EditCustomer>Some arbitrary text</GEN:Button>

One of the most common mistakes made by developers not familiar with XML syntax is to use the first format without the “/” just before the closing “>“.

Correct: <GEN:Button Name=“EditCustomer”/>               note: tag ends with />

Incorrect: <GEN:Button Name=“EditCustomer”>              note: missing / before >

The second format is still valid XML if it is followed at some later point by </GEN:Button>.  Otherwise it becomes invalid because the tag is not “closed”.  This is also similar to some HTML tags, such as <table> which must be closed by </table>.

The Name attribute is a required attribute for all code generation tags, e.g.:

<GEN:Button Name=“OK” />

Several special names cannot be used as Name values in code generation tags:

Note, that you should not change the value of the Name attribute directly in the HTML Editor, instead use (ID) property in the Property Sheet:

See Also

A Hello World Example Using the Image Tag

Code Generation Tag Properties

Overriding Properties

Field Display Tags

FieldValue Tag

FieldLabel Tag

FieldStatistic Tag

Record Tag

Layout Tags

Layout tags display free form content on the page.  You can specify the content in the Property Sheet.  There are two cases where it might be useful to use layout tags:

  1. Developer specified content:  In some cases, the content is not known at the time the pages are designed, such as the current date or the name of your client company in a copyright notice.  In this case, you can set the content in the Property Sheet.

  2. Programming control:  Static text in your Web page cannot be accessed or changed programmatically.  To programmatically change the contents of the page or hide some controls, the contents must be created as ASP.NET controls.  For example, to personalize a thank you message to your most valued customers, you can access the control and change the message and the visibility of the control programmatically.

HTML Tag

HyperLink Tag

Image Tag

Label Tag

Literal Tag

Text Tag

 

Table Tags

Table Tag

TabContainer Tag

TabPanel Tag

SearchFilter Tag

Table Component Tags

The Table Component tags create various statistical and pagination control components related to a table.

FieldLabel Tag

FieldStatistic Tag

Literal Tag

Pagination Tag

Table Tag

Button Tags

The Button tags display three button types on a page.

Image Tag

ImageButton Tag

LinkButton Tag

Pagination Tag

PushButton Tag

Filter Tags

The Filter tags create various filters and search control components related to a table.

FieldFilter Tag

SearchFilter Tag

Component Use Tags

The Component Use tag lets you include other reusable components that you may have created.  Iron Speed Designer creates some standard components that you can use and you can create your own reusable components.

Menu Tag

Use Tag