ASPxCaptcha.Code Property
Gets the textual representation of the code automatically generated by the control and displayed within the challenge image.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
NuGet Package: DevExpress.Web
#Declaration
#Property Value
Type | Description |
---|---|
String | A String value representing the automatically generated code. |
#Remarks
We recommend you to check the Code property value in the Page.Init event handler because the control generates the code before the Page_Load event. You get a different captcha code in all event handlers that occur later than the Page.Init event. Refer to the BC4085 - ASPxCaptcha - The Captcha code’s generation logic has been changed Breaking Change description for more information.
protected void Page_Init(object sender, EventArgs e) {
if(IsPostBack) {
bool isCaptchaValid = Captcha.Code == Request["TbCode"];
ValidateCodeMessage.InnerText = String.Format("The submitted code is {0}", isCaptchaValid ? "correct" : "incorrect");
ValidateCodeMessage.Style.Add(HtmlTextWriterStyle.Color, isCaptchaValid ? "green" : "red");
}
}
#Online Demo
ASPxCaptcha - Custom Appearance