Tuesday, July 17, 2012

Hyperlink Format String

The Hyperlink Format String property allows formatting fields as hyperlinks that can use the field values as parameters.

Start SQL Server Management Studio. Right-click on Databases node, and select New Database.

Create New Database in SQL Server Management Studio.

Assign the database the name of FormatString, and press OK to create the server.

Right-click on Databases / FormatString / Tables node, and select Add New Table.

Add New Table to FormatString database.

Add the following columns:

Column Name Data Type Allow Nulls
ProductID int False
ProductName nvarchar(50) False
Price money True
PictureUrl nvarchar(100) True

Right-click on ProductID column and select Set Primary Key.

Set ProductID as Primary Key.

Highlight ProductID column. Under Column Properties, specify the column as an identity.

Property Value
(Is Identity) Yes

Save the table as “Products”.

Switch to the web application generator. Create a new Web Site Factory project from the FormatString database. When the project configuration is complete, activate the Project Designer.

In the Project Explorer, double-click on Products / container1 / view1 / grid1 / Price data field node.

Price data field of grid1 on the Products page.

Change the Hyperlink Format String:

Property New Value
Hyperlink Format String _blank:{PictureUrl}

Press OK to save the data field. Double-click on Products / container1 / view1 / grid1 / PictureUrl data field node.

PictureUrl data field of grid1 on the Products page.

Mark the data field as hidden:

Property New Value
The field is hidden True

Press OK to save. On the toolbar, press Browse button.

When the web application is loaded, create three new records on the Products page with the following values:

Product Name Price Picture Url
Standard 349 http://codeontime.com/images/Buy_CodeOnTimeStandard.gif
Premium 899 http://codeontime.com/images/Buy_CodeOnTimePremium.gif
Unlimited 2499 http://codeontime.com/images/Buy_CodeOnTimeUnlimited.gif

The value of Price field in the grid view is rendered as a clickable link.

Value in Price data field rendered as a link.

When you click on the link in the Price column, you will navigate to the PictureUrl.

Clicking on the Price data field link will navigate to the specified PictureUrl.

No comments:

You can find more about Code OnTime Generator, Data Aquarium Framework, and other great products here.


© 2010 Code OnTime LLC. Intelligent code generation software for ASP.NET. Visit us at http://codeontime.com