[英]disable button using javascript function in asp.net
我在嘗試禁用按鈕時遇到問題,這是我的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" />
更多信息,請點擊立即禁用按鈕
<script type="text/javascript">
var DisableButton = function () {
document.getElementById("<%=LoginButton.ClientID %>").disabled = true;
};
var EnableButton = function () {
document.getElementById("<%=LoginButton.ClientID %>").disabled = false; };
</script>
如果您想指向<asp:Button ID="LoginButton
那個ID,我認為
document.getElementById("<%=LoginUser.ClientID %>").disabled = true;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.