MVC刚刚学了一下,这个Button在cshtml里怎么调用?现在想加上CSS样式。
/// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <param name="id"></param>
/// <param name="labelText"></param>
/// <param name="value"></param>
/// <param name="isChecked"></param>
/// <param name="htmlAttributes"></param>
/// <returns></returns>
public static MvcHtmlString Button(this HtmlHelper helper, string BtID, string BtName, string BtValue, bool isChecked, IEnumerable<KeyValuePair<string, object>> htmlAttributes)
{
StringBuilder sb = new StringBuilder();
TagBuilder input = new TagBuilder("input");
input.GenerateId(BtID);
input.MergeAttribute("name", BtName);
input.MergeAttribute("type", "button");
input.MergeAttribute("value", BtValue);
if (htmlAttributes != null)
foreach (KeyValuePair<string, object> attribute in htmlAttributes)
{
input.Attributes[attribute.Key] = attribute.Value.ToString();
}
if (isChecked)
{
input.MergeAttribute("disabled", "disabled");
}
sb.AppendLine(input.ToString());
return MvcHtmlString.Create(sb.ToString());
}