![](https://i-blog.csdnimg.cn/blog_migrate/302daa7e7bea0a7a359f01920670cf26.png)
I took Jeff Atwood's CAPTCHA example and added a new event called "UserValidationEvent"
我以Jeff Atwood的CAPTCHA示例为例,并添加了一个名为“ UserValidationEvent”的新事件
Public Event UserValidationEvent As EventHandler
公共事件UserValidationEvent作为EventHandler
Then I raise the event at the VERY end of ValidateCaptcha I raise it:
然后,我在ValidateCaptcha的非常结尾处引发该事件:
RaiseEvent UserValidationEvent(Me, New EventArgs)
RaiseEvent UserValidationEvent(Me,New EventArgs)
I made it a separate event because I want the CaptchaControl to integrate with my blogging software WITHOUT any code on the server side. I didn't want to have to recompile dasBlog or check anything in the Page_Load.
我将其设置为一个单独的事件是因为我希望CaptchaControl与我的博客软件集成,而无需在服务器端添加任何代码。 我不想重新编译dasBlog或检查Page_Load中的任何内容。
I made the appropriate web.config changes as per Jeff's instructions, and I added the control to the CommentViewBox.ascx and put this code at the top:
我按照Jeff的说明进行了适当的web.config更改,并将控件添加到CommentViewBox.ascx并将此代码放在顶部:
<%@ Register TagPrefix="cc1" Namespace="WebControlCaptcha" Assembly="WebControlCaptcha" %>
<script Language="C#" Runat="Server">
protected void Foo(object sender, System.EventArgs e)
{
if (Page.IsPostBack == true && CaptchaControl1.UserValidated == false)
{
Response.Redirect(Request.RawUrl);
}
}<%@注册TagPrefix =“ cc1”命名空间=“ WebControlCaptcha”程序集=“ WebControlCaptcha”%> <脚本语言=“ C#” Runat =“ Server”> 受保护的void Foo(对象发送者,System.EventArgs e) { 如果(Page.IsPostBack == true && CaptchaControl1.UserValidated == false) { Response.Redirect(Request.RawUrl); } }
protected void Page_Load(object sender, System.EventArgs e)
{
//Ya, ya, I know I could have hooked this event up a number of ways
// including AutoEventWireUp but I like this fine, and it feels
// more explicit to moi.
CaptchaControl1.UserValidationEvent += new EventHandler(Foo);
}
</script>受保护的void Page_Load(对象发送者,System.EventArgs e) { //是的,我知道我可以通过多种方式来挂起此事件//包括AutoEventWireUp,但我很好,感觉//对moi更明确。 CaptchaControl1.UserValidationEvent + =新的EventHandler(Foo); } </ script>
There are a few Font issues to work out...he has it setup with a number of "no-no" fonts, while I'd prefer a list of "allowed" fonts.
有一些字体问题需要解决...他为它设置了许多“禁止”字体,而我希望使用“允许”的字体列表。