Sometimes in your Web application you might need your menu control to be available even when the user is scrolling down your page. Some Web Applications or Websites have a lot of contents on the page and when the user control down he forgets about the menus and sometimes it because a pain to always go up the page to find a menu. Sometimes it good if the menu can stay on the display while the user scrolls up and down. In this Article we are going to demonstrate on how to achieve this.
Introduction
Sometimes
in your Web application you might need your menu control to be available even
when the user is scrolling down your page. Some Web Applications or Websites
have a lot of contents on the page and when the user control down he forgets
about the menus and sometimes it because a pain to always go up the page to
find a menu. Sometimes it is good if the menu can stay on the display while the user
scrolls up and down. In this Article we are going to demonstrate on how to
achieve this.
Using
the code
We are going to user C# as our
language.
Start
Open Visual Studio and Create a New
Website. Automatically you will have an empty page defined for you like this
<%@ 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>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Go to Design View and you will notice
there is nothing on your page. In this Article we are going to use Ajax
Toolkit. I have covered the part where you add the tools to your toolbar. I
will not discuss this but you can see how i do it in my previous articles. Before i use the controls. After you have added the controls look for
the control named “AlwaysVisibleControlExtender”
as depicted in the Following Diagram
Drag and Drop the ScriptManager on your
page. Add the ScriptManager before the control on your page and add the Always
Visible Followed by the Panel Control and add a menu control inside the panel
control and make it more interestingly by adding more items as depicted in the
Following mark-up and diagram.

<%@ Page
Language="VB"
AutoEventWireup="false"
CodeFile="Default.aspx.vb"
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>Untitled
Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1"
runat="server">
</asp:ScriptManager>
</div>
<ajaxToolkit:AlwaysVisibleControlExtender ID="AlwaysVisibleControlExtender1"
runat="server"
TargetControlID="Panel1">
</ajaxToolkit:AlwaysVisibleControlExtender>
<br />
<br />
<asp:Panel ID="Panel1" runat="server">
<asp:Menu ID="Menu1" runat="server" BackColor="#FFFBD6" DynamicHorizontalOffset="2"
Font-Names="Verdana" Font-Size="0.8em" ForeColor="#990000" Orientation="Horizontal"
StaticSubMenuIndent="10px" Width="587px">
<StaticSelectedStyle BackColor="#FFCC66" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicHoverStyle BackColor="#990000" ForeColor="White" />
<DynamicMenuStyle BackColor="#FFFBD6" />
<DynamicSelectedStyle BackColor="#FFCC66" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticHoverStyle BackColor="#990000" ForeColor="White" />
<Items>
<asp:MenuItem Text="Home" Value="Home"></asp:MenuItem>
<asp:MenuItem Text="Products" Value="Products"></asp:MenuItem>
<asp:MenuItem Text="Forums" Value="Forums"></asp:MenuItem>
<asp:MenuItem Text="About us" Value="About us"></asp:MenuItem>
<asp:MenuItem Text="Contact us" Value="Contact us"></asp:MenuItem>
</Items>
</asp:Menu>
</asp:Panel>
<br />
<br />
<br />
<br />
<br />
<br />
WOW i did it<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
WOW i did it<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
WOW i did it<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
WOW i did it
</form>
</body>
</html>
And your Design should look like this

Now as you can see our Design is set
but we need to tell the extender what is the control that it is going to keep
visible. Let us go to our Mark-up again and add a Property of the Extender.
Change your mark-up to look like this
<ajaxToolkit:AlwaysVisibleControlExtender ID="AlwaysVisibleControlExtender1"
runat="server"
TargetControlID="Panel1">
</ajaxToolkit:AlwaysVisibleControlExtender>
As
you can see I have made some long list of page break. This is for the purpose
of our test. We need to see if the menu will still remain visible while we scroll.
Press F5 to run your application and scroll down and you will see that menu is
always available while you are scrolling as depicted in the following.
![]()

Conclusion
There
are many ways to achieve this, but this one is the simplest because it will
remove the burden of writing functions that will do this. Using AjaxToolkit
functionality can be achieved at ease.
Thank
you for visiting DotnetFunda
Vuyiswa
Maseko