日期:2014-05-16  浏览次数:20408 次

隐藏div显示问题
C# code

<%@ 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>


显示 时马上又隐藏了,我只单击了一下,请指教

------解决方案--------------------
不会啊? 是不是你asp.net服务器控件上作了另外的处理?
这样试试

HTML code
<!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>

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