Documentation > CMS Template API Library > Arg > Key

Key

The name of the arg.

Type

System.String

Code Example

C#

Sample:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// If the args were _sortOrder=Date&_name=Fred, the following would print
 
// key : _sortOrder  Value: Date
// key : _name  Value: Fred
 
foreach(Arg entry in context.PublishingArgs)
{
  Out.WriteLine("key : " + entry.Key + " Value: " + entry.Value);
}
 
 
//Get the value of _sortOrder
string sortorder = context.PublishingArgs["_sortOrder"]; 
 
// Does it have an argument called "_sortOrder" ?
bool hasSortOrder = context.PublishingArgs.HasArg("_sortOrder"); 
 
//Does it have any args?
bool hasSortOrder = context.PublishingArgs.HasArgs;  
 
//How many args does it have?
int numberOfArgs = context.PublishingArgs.Count;

Connect with Crownpeak