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
Expand file tree
/
Copy pathDropDown.cs
More file actions
88 lines (71 loc) · 2.31 KB
/
Copy pathDropDown.cs
File metadata and controls
88 lines (71 loc) · 2.31 KB
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
79
80
81
82
83
84
85
86
87
88
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}:DropDown runat=server></{0}:DropDown>")]
public class DropDown : System.Web.UI.WebControls.DropDownList
{
public string Name { get; set; }
public string Message { get; set; }
private string _Size { get; set; }
public InputSize Size
{
set
{
if (value == InputSize.Small)
_Size = "form-group-sm";
if (value == InputSize.Normal)
_Size = string.Empty;
if (value == InputSize.Big)
_Size = "form-group-lg";
}
}
public bool? FormGroup
{
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();
}
}
}
public string AdditionalStyle { get; set; }
public string Placeholder
{
set
{
base.Attributes["placeholder"] = value;
}
}
protected override void Render(HtmlTextWriter w)
{
w.Write(String.Format(@"<div style=""{2}"" class=""{3} {0} {1}"">", _Size, _State, AdditionalStyle, (FormGroup.HasValue) ? ((FormGroup.Value) ? "form-group" : "") : "form-group"));
if(Name != null)
w.Write(String.Format(@"<label class=""control-label"" for=""{0}"">{1}</label>", base.ClientID, this.Name));
base.CssClass += " form-control";
base.Render(w);
if(Message != null)
w.Write(String.Format(@"<p class=""help-block {0}"">{1}</p>", _MessageColor, Message ));
w.Write("</div>");
}
}
}