Documentation > CMS Template API Library > Arg > Key

Key

The name of the arg.

Type

System.String

Code Example

C#

Sample:
// 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