这可能是一个云雀,但对于recaptcha控件,因为有时需要很长的时间来渲染,这是可能的吗?
如果渲染时间超过5秒,我想停止渲染对象并显示我自己的验证码。
我会在页面加载时启动一个计时器,如果已经过了5秒,在recaptcha控件(prerender?),我会取消渲染,或使其不可见,或使其具有这种效果。它是第三方用户控件,因此我没有源代码。
更新:
我在发布后尝试了下面的代码。如果用户控件无法连接其服务器,也就是说,我将断开与Internet的连接,但当控件等待服务器返回时,如果有很长的暂停时间,则无法感觉到这一点。即使我将毫秒间隔更改为1,控件也会呈现。
<MTAThread()> _
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim ucChk As New UCExistenceChecker(recaptcha, Me)
Dim doFindUC As System.Threading.TimerCallback = AddressOf ucChk.FindUC
Dim stateTimer As System.Threading.Timer = New System.Threading.Timer(doFindUC, Nothing, 0, 5000)
End If
End Sub
Public Class UCExistenceChecker
Dim _r As Recaptcha.RecaptchaControl
Dim _pg As Page
Sub New(ByVal r As Recaptcha.RecaptchaControl, ByVal pg As Page)
_r = r
_pg = pg
End Sub
Sub FindUC(ByVal stateInfo As Object)
If _pg.FindControl("recaptcha") Is Nothing Then
_r.SkipRecaptcha = True 'This "unrenders" the control, sort of.
End If
End Sub
End Class