This repository was archived by the owner on Oct 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCheckBox.cs
78 lines (63 loc) · 1.85 KB
/
CheckBox.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace BootstrapControls
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:Checkbox runat=server></{0}:Checkbox>")]
public class CheckBox : System.Web.UI.WebControls.CheckBox
{
public string Label
{
get
{
if (ViewState["Label_" + ID] != null)
return ViewState["Label_" + ID].ToString();
else
return string.Empty;
}
set
{
ViewState["Label_" + ID] = value;
}
}
public override string Text
{
set; get;
}
public string Message { get; set; }
private string _State { get; set; }
private string _MessageColor { get; set; }
public InputOption State
{
set
{
_State = " has-" + value.ToString().ToLower();
if (value == InputOption.Error)
{
_MessageColor = "text-danger";
}
else
{
_MessageColor = "text-" + value.ToString().ToLower();
}
}
}
protected override void Render(HtmlTextWriter w)
{
Text = string.Empty;
w.Write(String.Format(@"<div class=""{0}"">", _State));
w.Write(@"<div class=""checkbox""><label>");
base.Render(w);
w.Write(Label + "</label>");
if (Message != null)
w.Write(String.Format(@"<p class=""help-block {0}"">{1}</p>", _MessageColor, Message));
w.Write("</div></div>");
}
}
}