Buy Support


Basics
Overview
Easy Code Customization
Sample Applications
Video Demos
Customers
Free Training
Pricing & Ordering
Download Now!

Product Tour
Product Tour
Web & Cloud Applications
Mobile Applications
SharePoint Applications
Charts and Reports
Security
Team Development
What's New in V11.0

Technical Materials
Training Courses
Online Help
Technical Forums
White Papers
One Day Web Apps E-book
System Requirements
Product Roadmap
Version History

Using URL Parameters

There are many contexts in which passing data from one page to another via the URL is a convenient means of transferring data.
- Alan Fisher, Chairman of Iron Speed, Inc.

February 7, 2006
Iron Speed Designer V3.2

Usage Contexts of URL Parameters

There are many contexts in which passing data from one page to another via the URL is a convenient means of transferring data. Parameters such as primary and foreign key values can be passed from one page to another through the destination page’s URL. These URL’s are specified in the tag’s Properties dialog. For example, you can create a "wizard" from a New Orders page to a New Order Details page by passing the OrderID of the new Orders record on the URL so that the OrderDetails.OrderID field is automatically set in the New Order Details page.

URL parameters are available in several contexts, including:

  • Button properties (Bindings tab in the button’s Properties dialog.) for passing URL parameters from one page to another when a button is clicked. For example, the primary key value (ID) of a table row entry can be passed to a Show Record page to display the full details of the selected record.
  • WHERE clauses (WHERE clauses in the Properties dialog, Bindings tab.) when selecting and displaying data. A URL parameter can provide a value that is compared to the record's field value when that record is read at runtime. Based on the comparison of the two, the record is either included in or excluded from the result set. When Iron Speed Designer generates your application, it creates the "addFilter" mechanism that applies the comparison.
  • Field initialization (of FieldValue tags in the Properties dialog, Bindings tab, Set Initial Value To section) when initializing FieldValue components. Use your URL parameters to provide custom field initialization values.

Select URL parameter to constrain the selection criteria by
a parameter passed into the control from the page’s URL.

URL Query String Format

A simple URL with a query string parameter is:

In this example, the text string "ID" is specified as the query string parameter in the tag's Properties dialog. The query string parameter "ID" is then used in the page's URL. The application recognizes "ID" as a valid query string parameter and uses the value assigned to ID in the URL as part of the generated SQL query.

The receiving page might use the query string parameter as part of a WHERE clause that filters, or limits, the data displayed in a table, e.g.:

Permissible Query String Parameters

The query string parameter can be any alphanumeric string you wish. It does not have to match the database table's field name or correspond to anything else. Your application will parse the query string, extract the appropriate parameter and value, and perform the record lookup in the appropriate database table.

In use, the query string parameter follows the URL, as does "ID" in this example:

Passing Primary and Foreign Key Values in URL’s

Parameters such as primary and foreign key values can be passed from one page to another through the destination page’s URL. Parameters and their values are passed as part of the URL and URL Parameters fields in the Properties dialog that are available for any of the buttons such as PushButton, LinkButton, and ImageButton; and for links such as Hyperlink.

Parameter names are specified in the URL field and the URL may contain multiple parameter names; substitution variables for the parameter values are specified in the URL Parameters field. The URL Parameters field in the Properties dialog specifies a comma delimited set of arguments that are passed on the URL and uses {0}, {1}, etc. to pick the first argument, second argument, etc. Note that the first argument is {0} since the arguments numbers are zero based.

Passing Primary Key Values Between Pages in URL’s

Passing primary key values from one page to another via URL’s is very straightforward. In the tag’s Properties dialog, specify:

Tag Property Setting
Button Command Redirect
URL {0}
Tag Property Setting
URL Parameters ID

This passes the primary key value to the destination page via the URL. Even though the argument is called "ID", what is passed to the URL is an XML element that specifies the full primary key of the record. If the primary key is composite key, the composite key is passed as an argument.

If the ID of the field is a single integer value, you can use the "FV" URL Parameter type to pass the value to the URL. However, if you later change the Id to a more complex key, your existing pages will not work correctly. As such, we recommend always using the "ID" or "PK" URL Parameter types to pass primary keys to other pages via an XML encoded composite key structure.

Passing Foreign Key Values Between Pages in URL’s

In the following example, the URL uses an argument {0} to indicate the substation of the first argument. The argument itself is specified in the URL Parameters field as FK:FK_Employees_Employees. This means that the parameter {0} will be substituted with the foreign key (FK) value as specified by FK_Employees_Employees. The FK_Employees_Employees name indicates a foreign key link between the employee table and another record in the Employees table (the manager of the employee).

Tag Property Setting
Button Text Add
Button Command Redirect
URL ./EmployeeFKLink.aspx?Employee={0}
URL Parameters FK:FK_Employees_Employees

Passing Virtual Primary Keys in URL’s

If you are using a database view or custom query (defined in Iron Speed Designer) as the source of data, make sure that the database view or custom query has a Virtual Primary Key (VPK) defined. (Virtual Primary Key functionality is only available in Iron Speed Designer Enterprise Edition).

If a virtual primary key is not defined, then your application will not be able to access the ID or the record or any field within the record since there is no "handle" available to read the record from the database. As such, passing a parameter such as ID or FV:EmployeeName will not result in the value being substituted for the parameters and you will see the URL still contain {0}, {1}, etc.

Passing Composite Key Values in URL’s

Most database tables have a single primary key such as an Id field. But, some tables may have a composite primary key such as a Customer table with First Name and Last Name as a composite key. In this case, you must pass the composite key in the URL as an XML structure containing both elements of the composite key, e.g., the first name field as "Fred" and last name field as "Jones". This is why Iron Speed Designer passes keys in an XML structure as the default.

The composite key XML structure is:

"cv" is the column value. For composite keys, your <key> structure will have several entries, one for each field in the composite key.

"c" is the column (field) name.

"v" is the column value, typically a numeric ID value or a text string.

If you are not using composite keys, you can change this very easily to a single field primary key by passing FV:Id instead of ID (PK). The differernce is that you are passing the field value of the "Id" field instead of the ID of the record. Make sure you spell the case of the field properly (e.g., Id, id, ID, iD or whatever) in the URL Parameters on the Bindings tab of the Properties dialog box for the button or other control.

Passing Field Values in URL’s

Passing Field Values Between Pages

The parameters passed as part of the URL are not limited to the primary and foreign keys. You can pass any field value, as well as display values using the URL Parameter types to pass any field value to a page via its URL. For example, to pass the first and last names from an Employee record, specify the URL and the URL Parameters as follows:

Tag Property Setting
Button Command Redirect
URL ShowEmployeePhotoRecord.aspx?First={0}&Last={1}
URL Parameters FV:FirstName,FV:LastName

Advantages and Limitations

There are many contexts in which passing data from one page to another via the URL is a convenient means of transferring data. By dynamically constructing the URL, the component can choose the page to which the user will be redirected. Also, using URL parameters, the component can pass data to the new page. This works even for components on different pages. However, because URLs are limited to a browser-specific maximum length, the quantity of data that can be passed to a new page is fairly limited. Also, a redirect will cause the current page to stop processing immediately. Therefore, some situations may require a combination of event interaction and page redirection.

Field Values vs. Display Values

The display values might be different than the field values. For example, for Boolean fields, the field value might be 1 or 0, but the display value might be True or False.

Example

This example passes the Id’s of two products to a page to show how parameter passing works. Two products are displayed as a result of this example.

Step 1: Create a new layout page file containing two products as follows:

Step 2: In the tag’s Properties dialog, set the data source as the Products table. Also specify the URL parameter as P1:

Tag Property Setting
Code generation tag Product
Table, view or query Products
URL parameter P1
Note: this can be any variable name you wish. It will be bound at run-time to the ID of the specific record passed in via the URL.

Step 3: Repeat this step for the second Product code generation tag. This time specify a different name for the query string parameter such as P2.

Step 4: Set the data binding properties of the FieldValue tags to their respective database fields.

Step 5: Build and run the application.

Passing Record ID from an Add Record Page

This example illustrates how to page pass a newly created record ID value (primary key value) from an Add Record page to another page. In this example, the user is redirected to another page when a “Save” button is clicked on an Add Record page. The newly created record ID is passed as a URL parameter to the redirected page.

Step 1: In Iron Speed Designer, double click the Save button on the Add Record page to display the Save button’s Properties dialog. Go to the Bindings tab on the Properties dialog box and set the following:

Tag Property Setting
Code generation tag SaveButton
Button Command Save data on page
Action After Command Go to specific URL
URL ../Employees/EditEmployeesRecord.aspx
URL Parameter EmployeeID=[Data Value From: EmployeeRecord]

Step 2: In the Bindings tab, click Add to add the URL parameter.

URL parameter Setting
URL parameter name EmployeeID
Data Value From EmployeeRecord
Parameter Value Primary key

Press OK on the URL Parameter dialog box.

Press OK on the Properties dialog box.

Step 3: Build and run your application.

About the Author

Alan S. Fisher
Co-Founder and Chairman of Iron Speed, Inc.

Mr. Fisher was a General Partner at Outlook Ventures, Inc., a venture capital company prior to co-founding Iron Speed, Inc. He co-founded Onsale, Inc. (now Egghead.com) and was its Chief Technology Officer from July 1994 to December 1999. He also Co-founded and was President of Software Partners, Inc, a developer and publisher of software products from August 1988 to July 1994. From April 1984 to August 1988, Mr. Fisher served as Technical Marketing Manager and Product Development Manager for Teknowledge, Inc., a developer of artificial intelligence software products. From June 1981 to April 1984, he served as a member of the technical staff for AT&T Bell Laboratories. Mr. Fisher serves on the Board of Directors of Infodata Systems Inc. (NASDAQ:INFD) an e-business consulting services company; He formerly served on the board of a number of companies including Onsale, Inc. (later Egghead.com and now Amazon.com), and FatBrain, Inc. an Internet retailer of technical and professional books.

Mr. Fisher received his B.S. in Electrical Engineering from the University of Missouri and received his M.S. in Electrical Engineering from Stanford University.

   
 

Terms of Service Privacy Statement