Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Drop Down Menu using ASP.NET

Options
  • 16-04-2004 2:28pm
    #1
    Moderators, Society & Culture Moderators Posts: 2,688 Mod ✭✭✭✭


    Hi everyone,

    <<<<<<<< Developing using Visual Studio.NET C# and ASP.NET >>>>>>>>>>

    Doing an ASP.NET web form and im looking to find out how to do a drop down menu system like that here on boards... see my attachment!

    any pointers on where to start?


Comments

  • Registered Users Posts: 3,548 ✭✭✭Draupnir


    Ive recently learned that these menus are done with Javascript and CSS so you just embed these into the old ASP.

    Check out the topic further down started by me RE: Drop down menus


  • Registered Users Posts: 640 ✭✭✭Kernel32


    Javascript, CSS and DHTML.

    If this is a requirement for a paid for project I highly recommend not trying to build it yourself and buying a component suite from someone like infragistics, price ranges from $600 to $1000 and will have everything you need. I am building a webapp with dropdown menus, editable grids, tabs, listbars and all that and never have to touch DHTML or Javascript, it all gets rendered from the server controls.


  • Moderators, Society & Culture Moderators Posts: 2,688 Mod ✭✭✭✭Morpheus


    Yes it is a paid for project, but as anyone who is reading my threads knows im fairly new to the .NET experience (im not new to coding though and would like to learn how to implement them for myself too), however, we are simply looking to implement a basic drop down list with links in it, no reason to spen €600 on something that may take me an hour or two to implement.


  • Registered Users Posts: 1,775 ✭✭✭Spacedog


    there is a plugin component that you can use to generate menus...

    http://www.aspnetmenu.com/

    think it costs money and stuff though.


  • Registered Users Posts: 4,276 ✭✭✭damnyanks


    Tree view might be of some use.

    http://msdn.microsoft.com/downloads/samples/internet/asp_dot_net_servercontrols/webcontrols


    Its DHTML when compiled or else HTML 3.2 if the browser doesnt support whatever is required to compile it into dhtml.


  • Advertisement
  • Closed Accounts Posts: 2,525 ✭✭✭JustHalf




  • Registered Users Posts: 4,276 ✭✭✭damnyanks


    Ooooh I posted in that as well... aren't I helpful :D


  • Moderators, Society & Culture Moderators Posts: 2,688 Mod ✭✭✭✭Morpheus


    Working in VS.NET using html and CSS

    OK,

    thanks for the help guys, figured out how to do the drop down menubar...

    now ive another question

    Ive an ASPX page with just my menu on it,

    Can i now have the same menu at the top of every new aspx page by linking each of them to the original "menu" aspx page?

    Basically i dont want to end up duplicating the menu code everytime i create a new aspx page on my webform application?


  • Registered Users Posts: 640 ✭✭✭Kernel32


    Use a UserControl. A UserControl is like a composite HTML control for ASP.Net, its has a .ascx extension and its code behind class inherits from System.Web.UI.UserControl. Its very powerful, it has its own seperate Page_Load event seperate from the container page Page_Load event. Its simple enough to do, in VS.Net create a new item that is a UserControl. Put your menu stuff on there. Create a new page and from the solution explorer drag the [usercontrol.ascx] file onto it. It will create a gray looking box which shows where the control will be rendered. One of the odd things I have found is that it doesn't create a protected member in the code behind to interact with the instance of the control. What I do is simple add it myself, something like this.. in this case the usercontrol is name ipMenuBar on the page and you would have to use your own namespace.

    protected iPlan.Nav.MenuBar ipMenuBar;

    You can do all sorts of cool stuff with this. What I do is have each page inherit an interface I defined seperately. The menubar tries to get a pointer to that interface. I use the interface to communicate between the page and the menu bar. Its got a readonly property that returns a list of items to add to the menu for that particular page. Its also got a method to process the commands that get clicked on the menu, like each page has its own implementation code for a Save but the class interface remains the same.

    The next version of VS.Net is supposed to have the concept of master template pages which will negate some of this.


  • Moderators, Society & Culture Moderators Posts: 2,688 Mod ✭✭✭✭Morpheus


    Did it with a style sheet, a user control and an aspx page which references the user control (i dragged and dropped it in the design mode) only prob is something to do with z-index and a label appearing infront of my drop down menus.

    Thanks for the help, its all sorted now except for the Z-index thingy,

    Ive a label coming up through the drop down menu, ive tried setting the labels z-index to zero, but it still appears?!?


  • Advertisement
  • Moderators, Society & Culture Moderators Posts: 2,688 Mod ✭✭✭✭Morpheus


    Hi, using C# and ASP.NET

    Ive developed a user control drop down menu and a style sheet for it.

    I want this menubar user control to appear at the top of every aspx page.

    To place it on a page, I now know that I open the aspx page in design mode and drag the menu control (DropDownMenu.ascx) file from the Explorer window onto the design workspace and it creates an icon which represents the use of my menu
    control on that page.

    This adds some code to the top of that pages HTML.

    <%@ Register TagPrefix="uc1" TagName="GenericDropDownMenu" Src="../GenericDropDownMenu.ascx" %>

    and places the following ucl tag into the form element:
    <uc1:GenericDropDownMenu id="GenericDropDownMenu1" runat="server"></uc1:GenericDropDownMenu>


    My project explorer has 2 subfolders containing an aspx page each,

    project explorer structure:
    Mysolution
      
    [B]-MyProject[/B]
          -MainPage.aspx
          -DropDownMenu.ascx
          -MyStyles.css
    [B] -Folder1[/B]
              -SubPage1
    [B] -Folder2[/B]
              -SubPage2
    
    Everything seems to work fine as long as the page using my menu, the menu user control, and the style sheet referenced by the menu user control are all at the same level within the explorer.


    i tried dragging the control onto each of SubPage1 and 2 but the menu appeared represented as a list of html weblinks rather than a nice drop down menu.

    It looked like there was no recognition of the styles i created in the style sheet.

    Any idea why this would happen? The only thing i can think of is that the style sheet is at a level above the pages trying to use it???

    please please please can someone help me?


  • Moderators, Society & Culture Moderators Posts: 2,688 Mod ✭✭✭✭Morpheus


    Hmmm... im getting good at answering my own posts...

    I added a copy of the style sheet to each of the sub folders and it works.... dunno if this is right, it seems like overkill to have to do this, but maybe a .NET person out there has used style sheets and knows why???

    Also my drop down menu appears on every page, which is what I want, BUT!!! it resizes slightly whenever i move off the start page.

    it gets slightly longer and taller and the text gets slightly bigger.... any ideas as to why this may happen?


Advertisement