using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;
using System.ComponentModel;
namespace Names.Util
{
public static class HtmlExtension
{
// Methods
public static string Button(this HtmlHelper helper, string value)
{
return ("<input type=\"button\" value=\"" + value + "\" />");
}
public static string Button(this HtmlHelper helper, string value, object htmlAttributes)
{
return ("<input type=\"button\" value=\"" + value + "\"" + HtmlAttributes(htmlAttributes) + "/>");
}
private static string HtmlAttributes(object htmlAttributes)
{
StringBuilder builder = new StringBuilder();
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(htmlAttributes))
{
builder.AppendFormat(" {0}=\"{1}\" ", descriptor.Name, descriptor.GetValue(htmlAttributes));
}
return builder.ToString();
}
public static string ResetButton(this HtmlHelper helper, string value)
{
return ("<input type=\"reset\" value=\"" + value + "\" />");
}
public static string ResetButton(this HtmlHelper helper, string value, object htmlAttributes)
{
return ("<input type=\"reset\" value=\"" + value + "\"" + HtmlAttributes(htmlAttributes) + "/>");
}
public static string SubmitButton(this HtmlHelper helper, string value)
{
return ("<input type=\"submit\" value=\"" + value + "\" />");
}
public static string SubmitButton(this HtmlHelper helper, string value, object htmlAttributes)
{
return ("<input type=\"submit\" value=\"" + value + "\"" + HtmlAttributes(htmlAttributes) + "/>");
}
}
}