gpt4 book ai didi

javascript - 在 asp.net 中使用 javascript 函数禁用按钮

转载 作者:行者123 更新时间:2023-11-28 00:20:33 26 4
gpt4 key购买 nike

我在尝试禁用按钮时遇到问题,这是我的 javascript 函数:

<script type="text/javascript">
var DisableButton = function () {
document.getElementById("<%= LoginButton.ClientID %>").disabled = true;
};
var EnableButton = function () {
document.getElementById("<%= LoginButton.ClientID %>").disabled = false; };
</script>

这就是按钮所在的位置

<asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false">
<LayoutTemplate>

<%-- some elements here: text boxes, etc --%>

<div>
<p class="submitButton">
<asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In"
ValidationGroup="LoginUserValidationGroup"/>
</p>
</div>
</LayoutTemplate>
</asp:Login>

它在其他页面中有效..但是在这里,我收到此错误

Description: 
An error occurred during the compilation of a resource required to service this request.
Please review the following specific error details and modify your source code appropriately.

Compiler Error Message:
CS1061: 'System.Web.UI.WebControls.Login' does not contain a definition
for 'LoginButton' and no extension method 'LoginButton' accepting a first argument of type
'System.Web.UI.WebControls.Login' could be found (are you missing a using directive or an assembly reference?)


Source Error:
document.getElementById("<%= LoginButton.ClientID %>").disabled = true;

此外,我从 google recaptcha 事件调用这些函数:

<div id="asd" class="g-recaptcha" data-callback="EnableButton" data-expired-callback="DisableButton" data-sitekey="site_key">

我在这里做错了什么?我错过了什么吗?

最佳答案

<script type="text/javascript">
function DisableButtons()
{
document.getElementById ("<%=Button2.ClientID %>").disabled = true;
document.getElementById ("<%=Button3.ClientID %>").disabled = true;
return true ;
}
</script>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return DisableButtons()" />
<asp:Button ID="Button2" runat="server" Text="Button" />
<asp:Button ID="Button3" runat="server" Text="Button" />

更多信息使用Instantly disable Button on click

Disabling Buttons within C# method

关于javascript - 在 asp.net 中使用 javascript 函数禁用按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30069313/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com