|
|||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionA DHTML menu is something many web developers use these days as those provide a friendly and hierarchical interface for users. In a project I’m working on, I need one of those, and I searched the web to find an ASP.NET control. There are some good examples of menu controls but none of them gives what really I want (cross-browser, VB.NET, code available, free, and with possibilities for nice styles). Then I found Sylvain Machefert’s work (in French). He is a web developer with good CSS, JavaScript and cross browser issues knowledge, who made a very compatible DHTML menu and released it to public. The menu even works on text based browsers, reading technologies for visually impaired considered, and the menu is not visible when printing your page. Also, it can be customized in many ways and it supports icon images. The list of compatible browsers:
Because Sylvain doesn’t have enough knowledge in .NET programming (at the time of this writing at least) he couldn’t release an ASP.NET custom control. There has been a previous example of a user control with Sylvain’s menu, made by guys at Sokhar (a web development company). However, there were a few issues with that one which didn’t go well with my project:
The only downside for some might be that the menu only supports one level branching. This is no problem for me because I believe more than two levels already messes up the looks of the page (and also I read an article on that matter). I thank first Sylvain for his great work, and then Sokhar for their contribution; it was an important influence for my code. BackgroundThis is the first update of this DHTML menu user control. In this release, I made some improvements I was planning after I made the first release. Well, what does the user control I made do? It reads which CSS file to use from the control property “ Using the codeBecause I send .vb code pages as well, you can improve this control. Implementation is actually easy. First, create a “databases” folder in your project (right click the project name in your Visual Studio Solution Explorer window, not the solution name, solution name is the one at the top; Add >> New Folder, rename it to “databases”), then right click on the “databases” folder in your Visual Studio Solution Explorer window, Add >> Add Existing Item. You select in the file selection window your Access database file named “cssmenudb.mdb” (or edit the one I’m sending and select that). Be careful with “File Type” in selection window, it must be “All Files” or you won’t see the database file. Now create a folder named “menu” in your project folder (again by right clicking on the project name in the Solution Explorer). Use right click Add >> Add Existing Item method on “menu” folder to add menu.ascx and menu.ascx.vb files from my project (you can select more than one file on that window). You also need to add JavaScript CSS and icon images as well in that folder. Then the menu user control has to be registered in the page you want it to be implemented, by adding the line: <%@ Register TagPrefix="userCtrl" TagName="CSSMenu" Src="menu/menu.ascx" %>
on top of the aspx page in HTML view, just below the <userCtrl:CSSMenu id="Menu1" runat="server" HRImage="lookxphr.gif"
FollowScroll="false" CenterMenu="true" DefaultHeight="25" DefaultWidth="95"
Vertical="true" DiffWidth="true" CSSFile="vertical.css">
</userCtrl:CSSMenu>
I recommend you to put it above the Let's examine the properties of menu control:
Points of InterestThis is one of the two stored procedures used in the Access database. As you can see (if you are familiar with this concept), the syntax is a bit different from SQL's one. PROCEDURE sp_mainMenuURL
PARAMETERS mainMenuTitleArg Text ( 255 );
SELECT tblMainMenu.mainURL
FROM tblMainMenu
WHERE tblMainMenu.mainMenuTitle = mainMenuTitleArg;
For those of you unfamiliar with SQL procedures, here is the stored procedure above in TSQL (SQL implementation of Microsoft SQL Server 2000): PROCEDURE sp_mainMenuURL
CREATE PROCEDURE sp_mainMenuURL
@mainMenuTitleArg NvarChar (255)
AS
SELECT mainURL
FROM tblMainMenu
WHERE mainMenuTitle=@mainMenuTitleArg;
GO
What to do next?I made many improvements in this release I wanted to after I made version 1.0. Now I think it's time to give the users the facility to have more than one menu in their project. Consider a case where some users (let's say customers) are supposed to get different main menu and submenu items and other users (let's say employees) other items. Of course, in that case, security and more database tables come into consideration. History
| ||||||||||||||||||||||||||||||