Return to doc.sitecore.com

4.  Define the Properties of the Control
Prev Next

Define the properties of the control. As long as the functionality of the CustomChecklist control is similar to that of a simple Checklist, the control should have the same properties:

1 #region Varibles
2   
3    private string fieldName = string.Empty;
4    private string itemID = string.Empty;
5    private string source = string.Empty;
6    private bool isEvent = true;
7   
8 #endregion Variables
9
10 #region Properties
11
12    public string FieldName
13    {
14       get
15       {
16          return fieldName;
17       }
18       set
19       {
20          fieldName = value;
21       }
22    }
23
24    public string ItemID
25   {
26      get
27      {
28         return itemID;
29      }
30      set
31      {
32         itemID = value;
33      }
34   }
35
36   public string Source
37   {
38      get
39      {
40         return StringUtil.GetString(source);
41      }
42      set
43      {
44         if(value.IndexOf('&') > -1)
45         {
46            source = value.Substring(0, value.IndexOf('&'));
47            if(value.ToLower().IndexOf("separator", value.IndexOf('&')) > -1)
48            {
49               string[] parameters = value.Split('&');
50               for(int i = 1; i < parameters.Length; i++)
51               {
52                  if(parameters[i].ToLower().IndexOf("separator") > -1)
53                  {
54                      Separator = parameters[i].Substring((parameters[i].IndexOf("=") > -1) ? parameters[i].IndexOf("=")+1 : 0);
55                  }
56               }
57            }
58        }
59        else
60        {
61           source = value;
62        }
63      }
64   }
65
66   public string Separator
67   {
68      get
69      {
70         if(ViewState[this.ClientID+"_separator"] != null)
71         {
72            return ViewState[this.ClientID+"_separator"].ToString();
73         }
74         else
75         {
76            return ", ";
77         }
78      }
79      set
80      {
81         ViewState[this.ClientID+"_separator"] = value;
82      }
83   }
84
85   public bool TrackModified
86   {
87      get
88      {
89         return base.GetViewStateBool("TrackModified", true);
90      }
91      set
92      {
93         base.SetViewStateBool("TrackModified", value, true);
94      }
95   }
96 #endregion Properties

Prev Next