Panel, Tabview, Propertie controls converted
Changed the html to output bootstrap html, masterpages load our belle css + bootstrap.min.js
This commit is contained in:
72
src/umbraco.controls/MenuSplitButton.cs
Normal file
72
src/umbraco.controls/MenuSplitButton.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace umbraco.uicontrols
|
||||
{
|
||||
public class MenuSplitButton : Panel
|
||||
{
|
||||
|
||||
public string Text { get; set; }
|
||||
public List<HtmlAnchor> HtmlAnchors { get; set; }
|
||||
|
||||
public string OnClientClick { get; set; }
|
||||
|
||||
public void AddLink(HtmlAnchor link)
|
||||
{
|
||||
if(HtmlAnchors == null)
|
||||
HtmlAnchors = new List<HtmlAnchor>();
|
||||
|
||||
HtmlAnchors.Add(link);
|
||||
}
|
||||
|
||||
protected override void Render(System.Web.UI.HtmlTextWriter writer)
|
||||
{
|
||||
writer.Write("</div>");
|
||||
base.Render(writer);
|
||||
this.Render(writer);
|
||||
writer.Write("<div class='btn-group>");
|
||||
}
|
||||
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
base.CssClass = "btn-group";
|
||||
|
||||
HtmlButton btn = new HtmlButton();
|
||||
btn.InnerText = Text;
|
||||
btn.Attributes.Add("class", "btn");
|
||||
this.Controls.Add(btn);
|
||||
|
||||
HtmlButton btnToggle = new HtmlButton();
|
||||
btnToggle.InnerHtml = "<span class='caret'></span>";
|
||||
btnToggle.Attributes.Add("class", "btn dropdown-toggl");
|
||||
btnToggle.Attributes.Add("data-toggle", "dropdown");
|
||||
this.Controls.Add(btnToggle);
|
||||
|
||||
Literal list = new Literal();
|
||||
this.Controls.Add(list);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("<ul class='dropdown-menu'>");
|
||||
|
||||
foreach (var htmlAnchor in HtmlAnchors)
|
||||
{
|
||||
sb.Append("<li><a ");
|
||||
foreach (var attr in htmlAnchor.Attributes.Keys)
|
||||
{
|
||||
sb.Append(attr + "='" + htmlAnchor.Attributes[attr.ToString()] + "' ");
|
||||
}
|
||||
sb.Append(">" + htmlAnchor.InnerText + "</a></li>");
|
||||
}
|
||||
|
||||
sb.Append("</ul>");
|
||||
list.Text = sb.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user