1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Bowin.Web.Controls.Mvc
- {
- public class ToolbarButton : BaseControl
- {
- public ToolbarButton()
- {
- }
- public string Text { get; set; }
- public string Icon { get; set; }
- public string OnClick { get; set; }
- public override string Render()
- {
- StringBuilder html = new StringBuilder();
- html.AppendFormat("<a {0} >", string.Join(" ", GetPropertyList().Select(x => string.Concat(x.Key, "=\"", x.Value, "\""))));
- if (!string.IsNullOrEmpty(this.Text))
- {
- html.Append(this.Text);
- }
- html.Append("</a>");
- return html.ToString();
- }
- protected Dictionary<string, string> GetPropertyList()
- {
- Dictionary<string, string> dictProperty = new Dictionary<string, string>();
- dictProperty.Add("class", "easyui-linkbutton");
- if (!string.IsNullOrEmpty(this.ID))
- {
- dictProperty.Add("id", this.ID);
- }
- if (!string.IsNullOrEmpty(this.Name))
- {
- dictProperty.Add("name", this.Name);
- }
- if (!string.IsNullOrEmpty(this.OnClick))
- {
- dictProperty.Add("href", "javascript:" + this.OnClick);
- }
- else
- {
- dictProperty.Add("href", "#this");
- }
- #region data-options
- var dictOptions = new Dictionary<string, string>();
- if (!string.IsNullOrEmpty(this.Icon))
- {
- dictOptions.Add("iconCls", "'" + this.Icon + "'");
- }
- dictOptions.Add("plain", "'true'");
- dictProperty.Add("data-options", string.Join(",", dictOptions.Select(x => string.Format("{0}:{1}", x.Key, x.Value))));
- #endregion data-options
- dictProperty.Add("onfocus", "this.blur()");
- return dictProperty;
- }
- }
- }
|