2012年7月22日 星期日

如何在提示視窗中顯示 asp.net 控制項

今天聽眾表示說他想要在按鈕上讓滑鼠移過去,出現提視小視窗並讓 asp.net 的控制項 gridview 在裡面顯示。

此次用的資料庫為 northwind,如果您的內容不是控制項而是 HTML,您也可以更換內容,以下為程式碼:

<!--把下面代碼加到<head>與</head>之間-->
    <style type="text/css">
    <!--
    body {
        padding-left:50px;
    }
    a.tip {
        color:red;
        text-decoration: underline;
        position:relative;
    }
    a.tip span{
        display:none; 
    }
    a.tip:hover{
        cursor:hand;
    }
    a.tip:hover .popbox{
        display: block;
        position:absolute;
        padding:10px;
        /* width:100px; 
        height:30px; */
        background:#000000;
        left:60px;
        top:30px;
        color:#FFFFFF;
        text-decoration: none;
    }
    -->
    </style>

...
...
...


<a href="http://www.o-asp.com" class="tip">把滑鼠移上來試試!
    <span class="popbox">
    <!-- 顯示內容開始 -->
    
    
    <asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" 
        CellPadding="4" DataKeyNames="EmployeeID" DataSourceID="northwind" 
        ForeColor="#333333" GridLines="None">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" 
                    InsertVisible="False" ReadOnly="True" SortExpression="EmployeeID" />
                <asp:BoundField DataField="LastName" HeaderText="LastName" 
                    SortExpression="LastName" />
                <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
                    SortExpression="FirstName" />
                <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
                <asp:BoundField DataField="Region" HeaderText="Region" 
                    SortExpression="Region" />
            </Columns>
            <EditRowStyle BackColor="#2461BF" />
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#EFF3FB" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#F5F7FB" />
            <SortedAscendingHeaderStyle BackColor="#6D95E1" />
            <SortedDescendingCellStyle BackColor="#E9EBEF" />
            <SortedDescendingHeaderStyle BackColor="#4870BE" />
        </asp:GridView>
        
        <asp:SqlDataSource ID="northwind" runat="server" 
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
        SelectCommand="SELECT [EmployeeID], [LastName], [FirstName], [City], [Region] FROM [Employees]">
    </asp:SqlDataSource>
    
    
    <!-- 顯示內容結束 -->
    </span>
    </a>

回aspnet目錄
回首頁

沒有留言 :

張貼留言

Related Posts Plugin for WordPress, Blogger...