Posted By

RockinForGod on 07/21/09


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


ASP.NET MVC - Anti-spam HTML Helper


 / Published in: C#
 

Outputs the required form elements to use the ValidateAntiSpamAttribute

  1. public static string AntiSpamConfirmation(this HtmlHelper helper)
  2. {
  3. TagBuilder label = new TagBuilder("label");
  4. label.Attributes.Add("for", "sixtimesnine");
  5. label.InnerHtml = "Are you a spam robot?";
  6.  
  7. TagBuilder p = new TagBuilder("p");
  8. p.InnerHtml = string.Format("{0}\n{1}\n{2}",
  9. label.ToString(TagRenderMode.Normal),
  10. helper.TextBox("sixtimesnine"),
  11. helper.Hidden("fourtytwo", "no"));
  12.  
  13. return p.ToString();
  14. }

Report this snippet  

You need to login to post a comment.