本文整理汇总了C#中Switch.RenderControl方法的典型用法代码示例。如果您正苦于以下问题:C# Switch.RenderControl方法的具体用法?C# Switch.RenderControl怎么用?C# Switch.RenderControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Switch
的用法示例。
在下文中一共展示了Switch.RenderControl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderBeginTag
public override void RenderBeginTag(HtmlTextWriter writer)
{
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"panel panel-default\">");
sb.Append(Environment.NewLine);
sb.Append("<div class=\"panel-heading\">");
sb.Append(Environment.NewLine);
Guid gPanel = Guid.NewGuid();
//Guid gSwitch = Guid.NewGuid();
if (CreateHideButton)
{
sb.Append(this.Title);
sb.Append("<div class=\"btn-group pull-right\" style=\"margin-top: -5px\">");
bSwitch = new Switch();
bSwitch.Size = Enumerations.SwitchSize.Small;
bSwitch.Checked = !PanelIsInitiallyHidden;
bSwitch.OffText = "<i class=\"glyphicon glyphicon-remove\">";
bSwitch.OnText = "<i class=\"glyphicon glyphicon-ok\">";
this.Controls.Add(bSwitch);
TextWriter txtWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(txtWriter);
bSwitch.RenderControl(htmlWriter);
sb.Append(txtWriter);
sb.Append("<script type=\"text/javascript\">");
sb.Append("$(window).load(function() {");
sb.Append("if($('#" + bSwitch.ClientID + "').attr('checked')){");
sb.Append("$('#" + gPanel + "').show();");
sb.Append("}");
sb.Append("else{");
sb.Append("$('#" + gPanel + "').hide();");
sb.Append("}");
sb.Append("});");
sb.Append("$('#" + bSwitch.ClientID + "').on('switchChange.bootstrapSwitch', function(event, state) {");
sb.Append("if(state){");
sb.Append("$('#" + gPanel + "').slideDown(500);");
sb.Append("}");
sb.Append("else{");
sb.Append("$('#" + gPanel + "').slideUp(500);");
sb.Append("}");
sb.Append("});");
sb.Append("</script>");
sb.Append("</div>");
}
else
{
sb.Append(this.Title);
}
sb.Append(Environment.NewLine);
sb.Append("</div>");
sb.Append(Environment.NewLine);
sb.Append("<div class=\"panel-body\" id=\"" + gPanel + "\">");
sb.Append(Environment.NewLine);
Literal litEnd = new Literal();
litEnd.Text = sb.ToString();
litEnd.RenderControl(writer);
}