public void RenderBaseControl( HtmlTextWriter writer )
{
string cssClass = this.CssClass;
writer.AddAttribute( HtmlTextWriterAttribute.Class, "input-group phone-number-box" + cssClass );
if ( this.Style[HtmlTextWriterStyle.Display] == "none" )
{
// render the display:none in the inputgroup div instead of the control itself
writer.AddStyleAttribute( HtmlTextWriterStyle.Display, "none" );
this.Style[HtmlTextWriterStyle.Display] = string.Empty;
}
writer.RenderBeginTag( HtmlTextWriterTag.Div );
this.CssClass = string.Empty;
bool renderCountryCodeButton = false;
var definedType = DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.COMMUNICATION_PHONE_COUNTRY_CODE.AsGuid() );
if ( definedType != null )
{
var countryCodes = definedType.DefinedValues.OrderBy( v => v.Order ).Select( v => v.Value ).Distinct();
if ( countryCodes != null && countryCodes.Any() )
{
if ( string.IsNullOrWhiteSpace( CountryCode ) )
{
CountryCode = countryCodes.FirstOrDefault();
}
if ( countryCodes.Count() > 1 )
{
renderCountryCodeButton = true;
writer.AddAttribute( HtmlTextWriterAttribute.Class, "input-group-btn" );
writer.RenderBeginTag( HtmlTextWriterTag.Div );
writer.AddAttribute( HtmlTextWriterAttribute.Class, "btn btn-default dropdown-toggle" );
writer.AddAttribute( HtmlTextWriterAttribute.Type, "button" );
writer.AddAttribute( "data-toggle", "dropdown" );
writer.RenderBeginTag( HtmlTextWriterTag.Button );
writer.Write( CountryCode + " " );
writer.AddAttribute( HtmlTextWriterAttribute.Class, "caret" );
writer.RenderBeginTag( HtmlTextWriterTag.Span );
writer.RenderEndTag();
writer.RenderEndTag(); // Button
writer.AddAttribute( HtmlTextWriterAttribute.Class, "dropdown-menu" );
writer.RenderBeginTag( HtmlTextWriterTag.Ul );
foreach ( string countryCode in countryCodes )
{
writer.RenderBeginTag( HtmlTextWriterTag.Li );
writer.AddAttribute( HtmlTextWriterAttribute.Href, "#" );
writer.RenderBeginTag( HtmlTextWriterTag.A );
writer.Write( countryCode );
writer.RenderEndTag();
writer.RenderEndTag(); // Li
}
writer.RenderEndTag(); // Ul
writer.RenderEndTag(); // div.input-group-btn
}
}
}
if ( !renderCountryCodeButton )
{
writer.AddAttribute( HtmlTextWriterAttribute.Class, "input-group-addon" );
writer.RenderBeginTag( HtmlTextWriterTag.Span );
writer.Write( "<i class='fa fa-phone-square'></i>" );
writer.RenderEndTag();
}
_hfCountryCode.RenderControl( writer );
( (WebControl)this ).AddCssClass( "form-control" );
if ( !string.IsNullOrWhiteSpace( Placeholder ) )
{
this.Attributes["placeholder"] = Placeholder;
}
base.RenderControl( writer );
writer.RenderEndTag(); // div.input-group
this.CssClass = cssClass;
}