Code generation tags instruct Iron Speed Designer what databound controls to generate. Code generation tags specify the database-connected tables, fields, filters, and other controls you want in your application. They are stored in the Quick Layout Spreadsheet and you can wrap them in additional text, HTML, and ASP.NET controls via the Cell Editor. When you drag a control from the Toolbox onto your page in Design Mode, you are very often adding a code generation tag.
|
|
Code generation tags instruct Iron Speed Designer which components to generate. This example shows how complex pages are constructed from with code generation tags in the Quick Layout Spreadsheet. |
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.
The code generation tags are divided into these groups:
|
Field Display Tags |
Record Tags |
Table Tags |
Table Component Tags |
|
FieldLabel |
Record |
Table |
FieldStatistics |
|
Filter Tags |
Layout Tags |
Button Tags |
Grouping Tags |
|
FieldFilter |
HTML |
ImageButton |
Group |
The specifics of each individual code generation tag are discussed elsewhere in more detail.
Iron Speed Designer inserts code generation tags into the Quick Layout Spreadsheet at locations where databound controls will be generated. Use the Properties dialog to specify the type of data being displayed and other properties. The Properties dialog saves its settings in a properties file, which is used to generate ASP.NET controls in your web pages.
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 generates 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. Iron Speed Designer uses the properties you set in the Properties dialog to generate the page component specified by each code generation tag.
The code generation tags will be replaced with one or more ASP.NET control tags in the ASPX or ASCX files generated 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 generated. In this case, the number of ASP.NET control tags generated 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 generating ASPX pages and ASCX controls.
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:
All code generation tags must be closed.
All code generation tags must be well formed.
All code generation tag attribute values must be enclosed in double quotes.
The Name attribute is required for most of the code generation tags. The value of the tag’s Name attribute has the following restrictions:
One word with no spaces
Must begin with a letter
Must be unique within a web page – except in repeating layouts such as repeating table rows
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:
Page
Self
Code Generation Tags
A Hello World Example Using the Image Tag