Documentation > CMS Template API Library > Input > ShowSelectList(String,String,Dictionary[String,String],List[String],Int32,SelectListSort,String,String)
ShowSelectList
Shows a list selector control, which allows the user to select values from a dictionary.
public System.Void ShowSelectList(String,String,Dictionary[String,String],List[String],Int32,SelectListSort,String,String)
Parameters
| Name | Description | Type |
|---|---|---|
| label | The label of the field when displayed. | System.String |
| listName | The name of the list where the fields will be stored. | System.String |
| entries | A list of key/value pairs that define the entries in the source list. Key is the text that is displayed, value gets stored. | Dictionary<String,String> |
| defaultValue | Optional: defaults to null. The list of default values that will appear in the destination list when nothing has been selected. | List<String> |
| size | Optional: defaults to -1. The number of rows displayed in the selector list. If not positive, uses default value. | System.Int32 |
| sort | Optional: defaults to . Specifies which of the two lists are automatically sorted. | CrownPeak.CMSAPI.SelectListSort |
| helpMessage | Optional: help message | System.String |
| popupMessage | Optional: The popup help message. | System.String |
Code Example
C#
Sample:
//example used in input.aspx
Input.StartControlPanel("ShowSelectList Example");
Dictionary<string, string> dictionary1 = new Dictionary<string, string>();
dictionary1.Add("Car_A", "Car A");
dictionary1.Add("Car_B", "Car B");
dictionary1.Add("Car_C", "Car C");
dictionary1.Add("Car_D", "Car D");
dictionary1.Add("Car_E", "Car E");
Input.ShowSelectList("Cars", "cars", dictionary1, sort: SelectListSort.Both, helpMessage: "this is a Help message.", popupMessage: "this is a PopUp message.");
Input.EndControlPanel();
//example used in output.aspx
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<h3>Selected Values from ShowSelectList</h3>
<ul>
<%
foreach (PanelEntry p in asset.GetPanels("cars"))
{
Out.WriteLine("<li>{0}</li>", p.Raw["cars"]);
}
%>
</ul>
</body>
</html>