Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 14814 |  Welcome, Guest!   Register  Login
Home > Articles > ASP.NET AJAX > How to make your Control Always Available While Scrolling in ASP.NET AJAX

How to make your Control Always Available While Scrolling in ASP.NET AJAX

1 vote(s)
Rating: 5 out of 5
Article posted by Vuyiswamb on 3/11/2010 | Views: 7887 | Category: ASP.NET AJAX | Level: Beginner red flag


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>

        &nbsp;<asp:ScriptManager ID="ScriptManager1" runat="server">

        </asp:ScriptManager>

       

    </div>

        <ajaxToolkit:AlwaysVisibleControlExtender ID="AlwaysVisibleControlExtender1" runat="server" TargetControlID="Panel1">

        </ajaxToolkit:AlwaysVisibleControlExtender>

        &nbsp;<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

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

Experience:11 year(s)
Home page:http://www.Dotnetfunda.com
Member since:Sunday, July 06, 2008
Level:NotApplicable
Status: [Member] [MVP] [Administrator]
Biography:Vuyiswa Junius Maseko is a programmer and a moderator in ".NetFunda. Vuyiswa has been developing for 9 years now. his major strength are C# 1.1,2.0,3.0,3.5 and sql and his interest are in Silverlight,WPF,C#,Kinect , Xbox Gaming Dev.
>> Write Response - Respond to this post and get points
Related Posts

In this article we will try to understand the 4 important steps to consume web service directly in Ajax. In this sample we will create a simple customer combo box as shown in the figure below. This customer combo box will be filled by calling the web service methods directly of the customer web service.

I was developing an order from for my client.There was a 5 fields-:Customer name,Item,Quantity ordered,Rate of the item and total amount(i.e quantity* rate).The order is to be taken by admin of the website. Earlier the requirement was that the admin will enter each item individually. i.e if a single customer gives order of 10 items ,each item is to be inserted individually,and the total amount(rate * quantity) is to be multiplied and displayed in the page.That was quite easy and i have completed with simple function in javascript.But the trouble arised when user changed his requirement.Now the requirement was he want to enter multiple items for the same customer,and as soon as he click place order button,the data should be inserted in database.Everything was done,but i faced a bit trouble in multiplying the textboxes value in repeater.i crawled the google,but failed to find the worthful stuff.Finall i managed it.see how

CalendarExtender is an ASP.NET AJAX control that is generally used with TextBox control. When user clicks in Textbox, Calendar control Pops up. Here I am discussing various properties of CalendarExtender .

In this article we are going to see how to access the webservice from Sys.Net.WebRequest where we can find the country by entering the IP address.

In the previous article of this series we created an SSIS Package. In this article we are going to execute that Package in our c# code. Remember in SQL 2000 there was something called DTS’s but in SQL 2005 there is SSIS. Now we are going to see how easy it is to execute our previous package.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/19/2013 8:05:41 AM