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

在asp.net中使用javascript函数禁用按钮,javascript,c#,asp.net,recaptcha,Javascript,C#,Asp.net,Recaptcha,我在尝试禁用按钮时遇到问题,下面是我的javascript函数: <script type="text/javascript"> var DisableButton = function () { document.getElementById("<%= LoginButton.ClientID %>").disabled = true; }; var EnableButton = function () { do

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

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

var DisableButton=函数(){
document.getElementById(“”).disabled=true;
};
var EnableButton=函数(){
document.getElementById(“”).disabled=false;};
这就是按钮所在的位置

<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;
说明:
编译服务此请求所需的资源时出错。
请查看以下特定错误详细信息,并适当修改源代码。
编译器错误消息:
CS1061:“System.Web.UI.WebControls.Login”不包含定义
对于“LoginButton”和不接受类型为的第一个参数的扩展方法“LoginButton”
可以找到“System.Web.UI.WebControls.Login”(您是否缺少using指令或程序集引用?)
源错误:
document.getElementById(“”).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">
         var DisableButton = function () {
            document.getElementById("<%=LoginButton.ClientID %>").disabled = true;
        };
        var EnableButton = function () {
            document.getElementById("<%=LoginButton.ClientID %>").disabled = false;         };
 </script> 
var DisableButton=函数(){ document.getElementById(“”).disabled=true; }; var EnableButton=函数(){ document.getElementById(“”).disabled=false;};
如果要指向

功能禁用按钮()
{
document.getElementById(“”).disabled=true;
document.getElementById(“”).disabled=true;
返回true;
}


这里在哪里?你知道使用两个不同的控件LoginUser.LoginButton.ClientID和LoginButton.ClientID吗?@Grundy在这里的意思是在特定的页面上。我现在才注意到,对不起。。但我已经改正了。我仍然得到相同的错误..在另一个页面中,您使用相同的
@Grundy just按钮。。尝试了很多东西,包括将
clientdmode
更改为
Static
您需要了解有关模板的信息您不能在javascript中直接使用服务器端控件的id。@JaiminSoni您可以使用
document.getElementById("<%=LoginUser.ClientID %>").disabled = true;
<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" />