我运行一个页面就报这个错,就仅仅一个页面,不和数据库打交道,我在button按钮里调用js方法是能运行的,一旦用了onclick就报错:
CS1061: “ASP.login_aspx”不包含“showAll”的定义,并且找不到可接受类型为“ASP.login_aspx”的第一个参数的扩展方法“showAll”(是否缺少 using 指令或程序集引用?)
----------------------------------------------------
 <script type="text/javascript">
    function showAll()
    {
    var uname=document.getElementById("TextBox1");
    var upwd=document.getElementById("TextBox2");
    if(uname==null)
    {
    alert("请输入用户名!");
    }
    if(upwd==null)
    {
    alert("请输入密码!");
    }
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div style="height: 608px" align="center" class="aso">
        <asp:TextBox ID="TextBox1" runat="server" 
            style="z-index: 1; left: 508px; top: 382px; position: absolute"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server" 
            style="z-index: 1; left: 508px; top: 435px; position: absolute; width: 150px;" 
            TextMode="Password"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" style="z-index: 1; left: 722px; top: 434px; position: absolute" Text="登  录" OnClick="showAll()"/>
        <asp:Image ID="Image1" runat="server" ImageUrl="~/images/login.jpg" CssClass="cc"/>
    </div>
    </form>
</body>

解决方案 »

  1.   

    OnClick="showAll()"   ->
    OnClientClick="showAll()"
      

  2.   

    <asp:Button ID="Button1" runat="server" style="z-index: 1; left: 722px; top: 434px; position: absolute" Text="登 录" OnClick="showAll()"/>
    换这个
    <input class="submit2" runat="server" value="登 录" onclick="showAll()" type="button" name="Submit3" />
    试试。
      

  3.   

    +1
    OnClick这个用在普通HTML标答就是JS单击事件,在服务器控件上,就是控件单击事件,在后台。CS
    写事件的,不是JS事件了。。
      

  4.   

    <asp:Button ID="Button1" runat="server" style="z-index: 1; left: 722px; top: 434px; position: absolute" Text="登 录" onclick="showAll()"/>
    或者直接把OnClick改onclick,也可以试试也有可能是OnClick="showAll()" ->
    OnClientClick="showAll()"

    多试几个就知道了,方法多种多样。