Chalk Extension to Create a Form

If you want to display a form element inside of a Graffiti CMS page, you can render it using an extension, widget, or plugin.  This tip will demonstrate how to utilize an extension to display a form.

[Chalk("customForm")]
public class CustomForm
{
   public string Write()
   {
    var sb = new StringBuilder();
    sb.AppendFormat("<form method='post' name='form' action='{0}'>", HttpContext.Current.Request.Url);
    sb.AppendLine("<input type='text' name='textbox1' />");
    sb.AppendLine("</form>");
    return sb.ToString();
   }
}

Build the above code into a .dll and copy it into your Graffiti CMS bin directory.  Then call the code in a .view file (index,layout,post) as customForm.Write().  If you have done everything correctly you will now see a form on your page(s).

 

4 Comments