I am facing an issue with disabling a button in a login template using c# code-behind. I have attempted to do it through a JavaScript method on the front-end, but so far, I have been unsuccessful. You can check out the details here!
This is what I have tried:
JavaScript method:
<script type="text/javascript>
var resetCaptcha = function () {
alert("Confirmation Expired. Please Answer Recaptcha.");
PageMethods.disable();
grecaptcha.reset();
};
</script>
Where the function is called:
<div class="g-recaptcha" data-sitekey="site-key" data-theme="dark"
data-expired-callback="resetCaptcha" data-callback="DisableButton"></div>
The code-behind method:
[WebMethod]
public void disable()
{
Button btn = new Button();
btn = LoginUser.FindControl("LoginButton") as Button;
btn.Enabled = false;
}
Additionally, I have declared the following:
<asp:ScriptManager ID="ScriptMgr" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
Despite all this, I still encounter the following error when the captcha is successfully completed:
Microsoft JScript runtime error: 'PageMethods' is undefined
If anyone has any insights or suggestions on resolving this issue, I would greatly appreciate your assistance.