位置:首页 > 编程专栏 > C#

js 设置服务端按钮控件(ASP.NET)不可用

js 设置服务端按钮控件(ASP.NET)不可用
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="DemoWebForm.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        window.onload = function () {
            // 设置按钮不可用
            document.getElementById('<%=btnLogin.ClientID %>').disabled = true;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:button runat="server" ID="btnLogin" text="登录" />
        </div>
    </form>
</body>
</html>


C# 社区推荐