Databases Reference
In-Depth Information
Dynamic Hyperlinks
Routes have a dual purpose. In addition to helping the ASP.NET runtime determine which
ASPX page will be used to handle a particular incoming request, they also determine how
hyperlinks pointing to the dynamic pages will be generated. There are several different
methods for generating hyperlinks in ASP.NET web applications. One of them involves the
DynamicHyperLink control supplied by Dynamic Data. This control inherits from the
ASP.NET HyperLink control and allows you to generate hyperlinks to dynamic pages. In
the following example, the name of the table and the required action are explicitly
specified.
<asp:DynamicHyperLink runat=”server”
ContextTypeName=”DataModel.NorthwindEntities”
TableName= ”Products” Action= ”List” Text=”Show all” />
The TableName property specifies the name of the MetaTable describing the target entity,
and the ContextTypeName specifies the name of the context class where the target entity is
defined. Depending on how the routing is configured, this control generates different
URLs without you having to modify any of its markup. Table 6.1 shows examples of the
different route definitions and URLs this control would generate based on them.
TABLE 6.1 Examples of URLs Generated by DynamicHyperLink
Route Definition URL Example
new DynamicDataRoute(“{table}/{action}.aspx”) http://localhost/Products/List.aspx
new DynamicDataRoute(“{table}/{action}”)
http://localhost/Products/List
new DynamicDataRoute(“{table}”)
http://localhost/Products
{
Action = PageAction.List
});
The DynamicHyperLink control can also be databound to an entity instance, in which case
it can automatically determine the ContextTypeName and the TableName and will generate
URLs that include names and values of its primary key columns in the query portion of
the address. The Details page template discussed earlier takes advantage of this functional-
ity by including the DynamicHyperLink controls as part of the ItemTemplate in the
FormView control as shown in the following extract:
<asp:FormView runat=”server” ID=”formView” DataSourceID=”dataSource”>
<ItemTemplate>
<asp:DynamicEntity runat=”server” />
<div class=”DDFormActions”>
<asp:DynamicHyperLink runat=”server” Action=”Edit” Text=”Edit” />
<asp:DynamicHyperLink runat=”server” Action=”Delete” Text=”Delete” />
<asp:DynamicHyperLink runat=”server” Action=”List” Text=”Show all”/>
 
Search WWH ::




Custom Search