日期:2014-05-19  浏览次数:20485 次

如何隐藏并显示一个按钮?
<form   id= "form1 "   runat= "server ">
        <div>
                <input   id= "Button3 "   type= "button "   value= "button "   />
        </div>
                <asp:Panel   ID= "Panel1 "   runat= "server "   Height= "50px "   Width= "125px ">
                        <input   id= "Button1 "   type= "button "   value= "要隐藏 "   />
                </asp:Panel>    
                  <asp:Panel   ID= "Panel2 "   runat= "server "   Height= "50px "   Width= "125px "   Visible= "false ">
                      <input   id= "Button2 "   type= "button "   value= "要显示 "   />    
                </asp:Panel>    
  </form>
==========================================================================
如何使用javascript,使得在点击Button3的同时让Panel1隐藏,并让Panel2显示?

------解决方案--------------------
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
<script type= "text/javascript ">
function show()
{
if(document.getElementById( "Panel1 ").style.display == "block ")
{
document.getElementById( "Panel1 ").style.display = "none ";
document.getElementById( "Panel2 ").style.display = "block ";
}
else
{
document.getElementById( "Panel1 ").style.display = "block ";
document.getElementById( "Panel2 ").style.display = "none ";
}
}
</script>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<input id= "Button3 " type= "button " value= "button " onclick= "show() "/>
</div>

<asp:Panel ID= "Panel1 " runat= "server " Height= "50px " Width= "125px " style= "display:block ">
<input id= "Button1 " type= "button " value= "要隐藏 " />
</asp:Panel>


<asp:Panel ID= "Panel2 " runat= "server " Height= "50px " Width= "125px " style= "display:none ">
<input id= "Button2 " type= "button " value= "要显示 " />
</asp:Panel>

</form>
</body>
</html>