@@ -20,12 +20,16 @@ public class Recaptcha2HtmlHelper : RecaptchaHtmlHelperBase
2020 {
2121 #region Constructors
2222
23+ /// <summary>
2324 /// Creates an instance of the <see cref="Recaptcha2HtmlHelper"/> class.
2425 /// </summary>
2526 /// <param name="publicKey">Sets the public key to be part of the recaptcha HTML.</param>
2627 public Recaptcha2HtmlHelper ( string publicKey )
2728 : base ( publicKey )
28- { }
29+ {
30+ DataType = null ;
31+ DataSize = null ;
32+ }
2933
3034 /// <summary>
3135 /// Creates an instance of the <see cref="Recaptcha2HtmlHelper"/> class.
@@ -36,7 +40,10 @@ public Recaptcha2HtmlHelper(string publicKey)
3640 /// <param name="tabIndex">Sets the tab index of the recaptcha HTML.</param>
3741 public Recaptcha2HtmlHelper ( string publicKey , RecaptchaTheme theme , string language , int tabIndex )
3842 : base ( publicKey , theme , language , tabIndex )
39- { }
43+ {
44+ DataType = null ;
45+ DataSize = null ;
46+ }
4047
4148 /// <summary>
4249 /// Creates an instance of the <see cref="Recaptcha2HtmlHelper"/> class.
@@ -48,10 +55,52 @@ public Recaptcha2HtmlHelper(string publicKey, RecaptchaTheme theme, string langu
4855 /// <param name="useSsl">Determines whether to use SSL in reCAPTCHA API URLs.</param>
4956 public Recaptcha2HtmlHelper ( string publicKey , RecaptchaTheme theme , string language , int tabIndex , SslBehavior useSsl )
5057 : base ( publicKey , theme , language , tabIndex , useSsl )
51- { }
58+ {
59+ DataType = null ;
60+ DataSize = null ;
61+ }
62+
63+ /// <summary>
64+ /// Creates an instance of the <see cref="Recaptcha2HtmlHelper"/> class.
65+ /// </summary>
66+ /// <param name="publicKey">Sets the public key of the recaptcha HTML.</param>
67+ /// <param name="theme">Sets the theme of the recaptcha HTML.</param>
68+ /// <param name="language">Sets the language of the recaptcha HTML.</param>
69+ /// <param name="tabIndex">Sets the tab index of the recaptcha HTML.</param>
70+ /// <param name="dataType">Sets the type of the recaptcha HTML.</param>
71+ /// <param name="dataSize">Sets the size for the recpatcha HTML.</param>
72+ /// <param name="useSsl">Determines whether to use SSL in reCAPTCHA API URLs.</param>
73+ public Recaptcha2HtmlHelper ( string publicKey , RecaptchaTheme theme , string language , int tabIndex , RecaptchaDataType ? dataType , RecaptchaDataSize ? dataSize , SslBehavior useSsl )
74+ : base ( publicKey , theme , language , tabIndex , useSsl )
75+ {
76+ DataType = dataType ;
77+ DataSize = dataSize ;
78+ }
5279
5380 #endregion Constructors
5481
82+ #region Properties
83+
84+ /// <summary>
85+ /// Gets or sets the size of the reCAPTCHA control.
86+ /// </summary>
87+ public RecaptchaDataSize ? DataSize
88+ {
89+ get ;
90+ set ;
91+ }
92+
93+ /// <summary>
94+ /// Gets or sets they type of the reCAPTCHA control.
95+ /// </summary>
96+ public RecaptchaDataType ? DataType
97+ {
98+ get ;
99+ set ;
100+ }
101+
102+ #endregion Properties
103+
55104 #region Public Methods
56105
57106 /// <summary>
@@ -111,6 +160,40 @@ public override string ToString()
111160 sb . Append ( string . Format ( " data-tabindex=\" {0}\" " , TabIndex ) ) ;
112161 }
113162
163+ if ( DataSize != null )
164+ {
165+ string dataSize = null ;
166+
167+ switch ( DataSize )
168+ {
169+ case RecaptchaDataSize . Compact :
170+ dataSize = "compact" ;
171+ break ;
172+ default :
173+ dataSize = "normal" ;
174+ break ;
175+ }
176+
177+ sb . Append ( string . Format ( " data-size=\" {0}\" " , dataSize ) ) ;
178+ }
179+
180+ if ( DataType != null )
181+ {
182+ string dataType = null ;
183+
184+ switch ( DataType )
185+ {
186+ case RecaptchaDataType . Audio :
187+ dataType = "audio" ;
188+ break ;
189+ default :
190+ dataType = "image" ;
191+ break ;
192+ }
193+
194+ sb . Append ( string . Format ( " data-type=\" {0}\" " , dataType ) ) ;
195+ }
196+
114197 sb . Append ( "></div>" ) ;
115198
116199 return sb . ToString ( ) ;
0 commit comments