Chalk Plugin to Respond to a Form Post

The previous tip demonstrated how to create a form in a Graffiti post.  The next step is to respond to that event in some way or another.  This post will demonstrate one way to handle an event from a form post using a Graffiti plugin.

public class PostLinkButton : GraffitiEvent
{
public override string Name
{
get
{
return “Form Post”;
}
}

public override string Description
{
get
{
return “This plug-in reacts to a Form Post Event.”;
}
}

public override void Init(GraffitiApplication ga)
{
ga.RenderPostBody += new RenderPostBodyEventHandler(ga_RenderPostBody);
}

void ga_RenderPostBody(StringBuilder sb, PostEventArgs e)
{
if (HttpContext.Current.Request.Form[“__HiddenVariable”] != null)
sb.Append(“Form Value (First Name): ” + HttpContext.Current.Request.Form[“FirstName”]);
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *