|
The Parameters descriptor captures objects or collections used as parameters. This does not play a major role in post back or submit events. This is because the view state is automatically posted back to server, which allows access to all objects and parameters on the page. However, the parameters could hold a set of parameter descriptors that allow the definitions of key and value pairs, for link and GET requests. This is illustrated in the next section.
Link or GET Request Parameters
PARAMETERS DESCRIPTOR |
id |
identity |
parent-id |
|
caption |
|
description |
|
value |
|
|
|
PARAMETER DESCRIPTOR |
id |
value |
required |
| referer |
yourassoc.com |
|
| customerId |
{bb.CustomerId} |
|
The implementation code would be as shown below.
<asp:hyperlink id="AssocLink" runat="server" navigateurl=
'<%# String.Format("http://associates.com.aspx?referer=yourassoc.com&custemerId={0}}", Eval("CustemerId")) %>' text='Legal Associates'/>
The hyperlink control that could be used within a GridView, provide a more elegant means of implementing the parameters associated. The specification is shown below.
PARAMETERS DESCRIPTOR |
id |
identity |
parent-id |
|
caption |
|
description |
|
value |
|
|
|
PARAMETER DESCRIPTOR |
id |
value |
required |
| id |
{datasource1[].CustomerID} |
|
| city |
{datasource1[].City} |
|
Whereas the implementation is as shown below.
<asp:HyperLinkField runat="server" DataTextField="CustomerName" DataNavigateUrlFields="CustomerID,City" DataNavigateUrlFormatString= "http://yoursite.com/showcustomer.aspx?id={0}&city={1}" />
Data Model Parameters
Normally, the parameters that are used to determine columns to select, insert, primary keys, or where clause parameters are defined in the model. On the ASP.NET these parameters are shown and implemented as part of page. This scheme is more amenable to dragging data and dropping unto components in the IDE. With complex and large projects, such scheme might become intractable. The LINQ data source provides option for abstracting such details into the model.
dWebSpec is meant to capture specification and not to enforce programming patterns or styles. If model parameters are needed, they could be captured. The parameters descriptors are general enough in nature that they could capture certain aspects of the model parameters.
An example of this is specification for where parameters used to narrow down the selection of rows; this is illustrated below.
PARAMETERS DESCRIPTOR |
id |
CategoriesParam |
parent-id |
behaviors[3] |
caption |
|
description |
WhereParameters |
value |
|
|
|
PARAMETER DESCRIPTOR |
id |
value |
required |
| 0 |
forms[0].elements[CategoryList] |
|
The implementation would be as shown below.
<asp:LinqDataSource ID="CategoryDataSource" ContextTypeName="NorthwindDataContext" TableName="Products" AutoGenerateWhereClause="true" Runat="Server"> <WhereParameters> <asp:ControlParameter Name="CategoryID" PropertyName="SelectedValue" Type="Int32" /> </WhereParameters> </asp:LinqDataSource>
The asp:XXXParameter used depends on the value specified. This is shown in the table below.
The value could be from form input element, cookie, query string, or session.
Value Type |
Example |
Parameter Type |
Description |
Form input element |
forms[0].elements[CategoryList] |
ControlParameter |
The value is obtained from the element specified.
The id of the element would correspond to ControlID.
The values of elements are obtained from different properties. For some it is Text, whereas it could also be SelectedValue for some. This property name would be entered into the PropertyName of the ControlParameter.
The property name for different elements is shown below.
- Calendar..::.SelectedDate
- CheckBox..::.Checked
- DetailsView..::.SelectedValue
- FileUpload..::.FileBytes
- GridView..::.SelectedValue
- Label..::.Text
- TextBox..::.Text
- TreeView..::.SelectedValue
|
Cookie |
{Request.Cookie[age]} |
CookieParameter |
Only single-valued cookies are supported. |
Query String |
{Request.QueryString[age]} |
QueryStringParameter |
Sets a parameter to the value of a QueryString field |
Session |
{Session[total]} |
SessionParameter |
Sets a parameter to the value of a Session object. |
|