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 pathRadioButton.cs
More file actions
111 lines (96 loc) · 2.94 KB
/
Copy pathRadioButton.cs
File metadata and controls
111 lines (96 loc) · 2.94 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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}:RadioButton runat=server></{0}:RadioButton>")]
public class RadioButton : System.Web.UI.WebControls.RadioButton
{
public override bool Checked
{
get
{
bool s = false;
if (ViewState["Checked_" + this.ID] != null)
{
if (bool.TryParse(ViewState["Checked_" + this.ID].ToString(), out s))
{
return (bool)ViewState["Checked_" + this.ID];
}
else
{
return false;
}
}
else
return false;
}
set
{
ViewState["Checked_" + this.ID] = value;
}
}
public string Value
{
get
{
if (ViewState["Value_" + this.ID] != null)
return ViewState["Value_" + this.ID].ToString();
else
return string.Empty;
}
set
{
ViewState["Value_" + this.ID] = value;
}
}
public string GroupValue
{
get
{
return Context.Request[base.GroupName];
}
}
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)
{
var viewstateVal = Context.Request[base.GroupName];
if(Value == viewstateVal && (!string.IsNullOrWhiteSpace(Value) && !string.IsNullOrWhiteSpace(viewstateVal)))
{
Checked = true;
}
var check = (Checked) ? "checked" : "";
w.Write(String.Format(@"<div class=""{0}"">", _State));
w.Write(@"<div class=""radio""><label>");
w.Write("<input id=\"" + base.ClientID + "\" ");
w.Write("type=\"radio\" ");
w.Write("name=\"" + base.GroupName + "\" ");
w.Write("value=\"" + Value + "\" " + check + " />");
w.Write(base.Text);
w.Write("</label></div>");
w.Write("</div>");
}
}
}