Captcha Control in DotNetNuke/DNN Module

I need to add Captcha Control for couple of contact and submission forms to stop possible spam bots. I tried with the similar way I approched In previous website application developed in ASP.NET. But, Its even too easy to add Captcha capability in forms than we do for simple websites. DotNetNuke/DNN is having a built in Captcha control which can be used on contact and submission forms.

First you need to add register tag for the control on your module user control. This will allow to create Captcha control and use it in code. The register line goes as:

<%@ Register TagPrefix="dnn" Assembly="DotNetNuke" Namespace="DotNetNuke.UI.WebControls"%>

Next, is you need to create the control in ascx page as:

<dnn:CaptchaControl runat="server" ID="dnnCaptchaControl" ErrorStyle-CssClass="NormalRed" cssclass="Normal" ErrorMessage="The typed code must match the image, please try again" CaptchaHeight="35" CaptchaWidth="120" />

Believe me, you are done with DNN Captcha control! You only need to validate whether the entered value for captcha by user is correct or not. You can write below code in contact/sybmission form's submit button click event:

if(ctlCaptcha.IsValid)
{
   //Captcha is valid! Code to submit the contact/submission form...
}

else

  return;

Comments

# re: Captcha Control in DotNetNuke/DNN Module

Thursday, September 17, 2009 11:01 PM by dddfdfd

ccvc  vdfd df df