回发期间的Recaptcha消失 [英] Recaptcha disappears during PostBack
问题描述
我看到的就在这里与ASP.net的UpdatePanel使用的Recaptcha的一对夫妇的其他职位,但还没有发现,解决我的问题的答案。
I have seen a couple of other posts on here regarding the use of Recaptcha with ASP.net UpdatePanels but have not yet found an answer that solves my problem.
下面是我的ASPX code:
Here is my ASPX code :
<asp:UpdatePanel ID="updRecaptcha" runat="server" UpdateMode="Always">
<ContentTemplate>
<recaptcha:RecaptchaControl ID="btnrecaptcha" runat="server" Theme="clean" PrivateKey"<%$ Resources: General, CaptchaPrivateKey %>" PublicKey="<%$ Resources: General, CaptchaPublicKey %>" />
<asp:Label ID="recaptchaerror" runat="server" style="color: Red;"/>
</ContentTemplate>
</asp:UpdatePanel>
所以使用多个的.Net验证控件(例如的RequiredFieldValidator)的用户控件中的ReCaptcha控制生活。我需要让程序继续之前valdiate的ReCaptcha和ASP.net控制。
So the Recaptcha control lives within a user control that uses several .Net validation controls (e.g. RequiredFieldValidator). I need to valdiate the Recaptcha and the ASP.net controls before allowing the process to continue.
如果任何验证的失败(或的Recaptcha .NET),然后的ReCaptcha控制消失。纵观HTML源代码,该控件不加载回发后在所有 - eventhough我说的是UpdatePanel的更新
If any of the validation fails (Recaptcha or .Net) then the Recaptcha control disappears. Looking at the HTML source, the control isn't loading at all after the Postback - eventhough I am telling the UpdatePanel to update.
我不能完全重新加载页面,这一切都出现在页面顶部覆盖层和有其他表单域在页面上落后。
I can't reload the page completely as this all appears as an overlay on top of the page and there are other form fields on the page behind.
请帮帮忙!
编辑:
从C#时的ReCaptcha失败我打电话这个code:
From C# when the Recaptcha fails I am calling this code :
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "InvalidRecaptcha", "alert('Recaptcha Failed');Recaptcha.reload();alert('Recaptcha Reloaded');", true);
这两个警报报表火,但仍的Recaptcha不会加载。
Both of the alert statements fire but the Recaptcha still does not load.
推荐答案
忘记的ScriptManager。所有你需要的是这个脚本在页面中。相应地更改您的标识符:
Forget the ScriptManager. All you need is this script in the page. Change accordingly for your identifiers:
<script type="text/javascript">
// RECAPTURE CODE FOR RELOADING AFTER INCORRECT ENTRY
if (typeof Sys != 'undefined') {
var requestManager = Sys.WebForms.PageRequestManager.getInstance();
requestManager.add_endRequest(function(sender, args) {
$('<div id="recaptcha_widget_div"/>').appendTo('#recaptcha_widget_div2');
if (typeof Recaptcha != 'undefined') {
Recaptcha.create(recaptcha_key, "recaptcha_widget_div",
{
theme: "red",
callback: Recaptcha.focus_response_field
});
}
});
}
这篇关于回发期间的Recaptcha消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!