<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!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">
        function show() {
            document.getElementById("div").style.display = "block";
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <div id="div" style="display:none">用户名:<asp:TextBox ID="name" runat="server" Width="70px" MaxLength="20"></asp:TextBox></div>
    <asp:Button runat="server" Text="显示" ID="btn" OnClientClick="show()" />
    </div>
    </form>
</body>
</html>显示 时马上又隐藏了,我只单击了一下,请指教

解决方案 »

  1.   

    style="display:none"
    外层是隐藏的
      

  2.   

    <div id="div" style="display:none">用户名:
      

  3.   

    不会啊? 是不是你asp.net服务器控件上作了另外的处理?
    这样试试<!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">
            function show() {
                document.getElementById("div").style.display = "block";
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <div id="div" style="display:none">用户名:<input type='text'/></div>
        <input type='button' onclick="show()" />
        </div>
        </form>
    </body>
    </html>
      

  4.   

    不好意思。。少看见了一个</div>
    应该是你做了别的处理吧。。
      

  5.   

    http://topic.csdn.net/u/20120319/13/6c1074a6-e77d-4b6e-a750-830617eda782.html