HoverMenu控件的功能是实现鼠标移过显示一个自定义的菜单,把一个控件作为一个目标的菜单显示。如Panel控件。
属性列表:
TargetControlID: 显示的Plane的ID
HoverCssClass: 显示的Plane的CSS
PopupPostion: 悬浮的位置:Left (默认), Right, Top, Bottom, Center
OffsetX/OffsetY: 相对于默认值的偏移值
PopDelay :出现Plane的延时,默认是100.
Animations :参照前面动画控件Animations
实例解析一、当移动到文本框上显示菜单,选择其中一项文本框获得相应值
1.UI界面:
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
</div>
<asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton1</asp:LinkButton><br />
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">LinkButton2</asp:LinkButton><br />
<asp:LinkButton ID="LinkButton3" runat="server" OnClick="LinkButton3_Click">LinkButton3</asp:LinkButton></asp:Panel>
<cc1:hovermenuextender id="HoverMenuExtender1" runat="server" offsetx="-1" offsety="-1"
popupcontrolid="Panel1" popupposition="Bottom" targetcontrolid="TextBox1"></cc1:hovermenuextender>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</form>
2.后台:
protected void LinkButton1_Click(object sender, EventArgs e)
{
TextBox1.Text = LinkButton1.Text.ToString();
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
TextBox1.Text = LinkButton2.Text.ToString();
}
protected void LinkButton3_Click(object sender, EventArgs e)
{
TextBox1.Text = LinkButton3.Text.ToString();
}
实例解析二、使用此控件实现GridView的编辑和删除
注意:
四个按钮的CommandArgument="Update" CommandName="Update"必须准备的写
SqlDataSource数据源必须指弄索引主键并启用INSERT,UPDATE,DELETE功能
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" Width="623px">
<Columns>
<asp:TemplateField HeaderText="UserName" SortExpression="UserName">
<EditItemTemplate>
<asp:Panel ID="PanelUpdate" runat="server" Height="50px" Width="125px">
<asp:LinkButton ID="LinkButtonUpdata" runat="server" CommandArgument="Update" CommandName="Update">更新/asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButtonChanel" runat="server" CommandArgument="Cacel" CommandName="Cancel">取消</asp:LinkButton> </asp:Panel>
<asp:Panel ID="PanelEdit" runat="server" Height="50px" Width="125px">
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("UserName") %>'></asp:TextBox>
</asp:Panel>
<cc1:HoverMenuExtender ID="HoverMenuExtender2" runat="server" OffsetX="1" OffsetY="-1" TargetControlID="PanelEdit" PopupControlID="PanelUpdate" PopupPosition="Left">
</cc1:HoverMenuExtender>
</EditItemTemplate>
<ItemTemplate>
<asp:Panel ID="PanelDel" runat="server" Height="50px" Width="125px">
<asp:LinkButton ID="LinkButtonDel" runat="server" CommandArgument="Delete" CommandName="Delete">删除</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButtonEdit" runat="server" CommandArgument="Edit" CommandName="Edit">编辑</asp:LinkButton></asp:Panel>
<asp:Panel ID="PanelContent" runat="server" Height="50px" Width="125px">
<asp:Label ID="Label1" runat="server" Text='<%# Bind("UserName") %>'></asp:Label>
</asp:Panel>
<cc1:HoverMenuExtender ID="HoverMenuExtender3" runat="server" OffsetX="1" OffsetY="-1" TargetControlID="PanelContent" PopupControlID="PanelDel" PopupPosition="Left">
</cc1:HoverMenuExtender>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:db_04ConnectionString %>"
DeleteCommand="DELETE FROM [tb_Employee] WHERE [UserID] = @UserID" InsertCommand="INSERT INTO [tb_Employee] ([UserName]) VALUES (@UserName)"
SelectCommand="SELECT [UserID], [UserName] FROM [tb_Employee]"
UpdateCommand="UPDATE [tb_Employee] SET [UserName] = @UserName WHERE [UserID] = @UserID">
<DeleteParameters>
<asp:Parameter Name="UserID" Type="Int64" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="UserID" Type="Int64" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="UserName" Type="String" />
</InsertParameters>
</asp:SqlDataSource>