日期:2014-05-18  浏览次数:20486 次

新手上路,各位老师请指教
一个页面上有Button1,Button2,Panel1,Panel2,启动页面的时候有一个Panel1显示,Panel2不显示 
  当鼠标移动到Button1时,Panel1.Visible = true;Panel2.Visible = false; 
  当鼠标移动到Button2时,Panel2.Visible = true;Panel1.Visible = false; 


小弟是新手刚刚学.net想好好和各位大大学习,请说清楚点,急急急

------解决方案--------------------
<style type="text/css">
.panel { display:none }

</style>

<div style="padding-top:20px;padding-left:10px;border:solid 1px #CCC">
<input type="button" id="btn1" title="1" value="Button1" onmouseover="btn_over(this);" onmouseout="btn_out(this);" />&nbsp;&nbsp;&nbsp;
<input type="button" id="btn2" title="2" value="Button2" onmouseover="btn_over(this);" onmouseout="btn_out(this);"; />
<div>
<asp:Panel ID="panel1" runat="server" CssClass="panel" > aaaaaa</asp:Panel>&nbsp;&nbsp;&nbsp;
<asp:Panel ID="panel2" runat="server" CssClass="panel" >bbbb</asp:Panel>
</div>
</div>
</form>
<script type="text/javascript">
function btn_over(obj)
{
var s=obj.title;
document.getElementById("panel"+s).style.display="block";
}
function btn_out(obj)
{
var s=obj.title;
document.getElementById("panel"+s).style.display="none";
}

</script>
------解决方案--------------------
在button1上 加上 onmouseover= "PanelN.Visible = 'true'"
onmouseout = "PanelN.Visible = 'false'"
看看效果吧

------解决方案--------------------
更正:
<div>
<asp:Panel ID="panel1" runat="server" > aaaaaa</asp:Panel>&nbsp;&nbsp;&nbsp;
<asp:Panel ID="panel2" runat="server" CssClass="panel" >bbbb</asp:Panel>
</div>
------解决方案--------------------
HTML code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>

<!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>Untitled Page</title>

    <script type="text/javascript"> 
      function over(obj) 
       { 
         var s=obj.id; 
         document.getElementById("panel"+s).style.display="block"; 
       } 
      function out(obj) 
       { 
         var s=obj.id; 
         document.getElementById("panel"+s).style.display="none"; 
       } 
     
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <input type="button" id="1" value="Button1" onmouseover="over(this);"
            onmouseout="out(this);" />
        <input type="button" id="2" value="Button2" onmouseover="over(this);"
            onmouseout="out(this);" />
        <br />
        <br />
            <br />
        <asp:Panel ID="panel1" runat="server" >
            panel1
        </asp:Panel>
        <b