Click here to Skip to main content
15,886,137 members
Articles / Web Development / HTML
Article

Combo Control

Rate me:
Please Sign up or sign in to vote.
4.56/5 (52 votes)
24 Jan 20052 min read 253.4K   2.8K   125   104
4-in-1 component for ASP.NET DHTML tab, tree, panel, menu - horizontal, vertical, pop-up, fading effects
Sample screenshot

Introduction

This is a control that will help to generate Tabs, Menus, Slider Bars and Tree Views. The controls are created "Just in Time" dynamically from XML.

Background

We see many web pages with lots of controls. Most of the controls available in the market are quiet expensive and they do only one job (i.e. if it is a menu control, we can't use it for tab). This control has all the built-in features, including security. For example, the user may want some of the items in the tab to be visible to a particular set of users, say administrators, and some less important to the common users. In that case, this plays an important role.

This control is very easy to use. The control exposes some public properties to set the data, the look 'n' feel and the events for the panel. By setting these properties, the collapsible panel can be used to group information very nicely.

Using the Code

The user control has six public properties:

  • Controltype - To mention the type of control (tab, tree, panel, menu)
  • Display - To set alignment of the control (only to Controltype = menu)
  • PageTitle - To set the page title (only to Controltype = tab)
  • MainMenuSelected - To set the Main menu (only to Controltype = tab)
  • SubMenuSelected - To set the Submenu selected (only to Controltype = tab)
  • ImageUrl - To set the Image in the tree (only to Controltype = tree).
ASP.NET
<%@ Register TagPrefix="CONTROL" Namespace="Controls" Assembly="FOURINONE"%>
 
// for tab
<CONTROL:FourinOne runat="server" 
  PageTitle="Congress Type" Controltype="tab"
  MainMenuSelected="2" SubMenuSelected="1" />
 
// for tree
<CONTROL:FourinOne runat="server" Controltype="tree" />
 
// for panel bar
<CONTROL:FourinOne runat="server" Controltype="panel" />
 
// for menu - horizontal
<CONTROL:FourinOne runat="server" Controltype="menu" Display="h" />
 
// for menu - vertical
<CONTROL:FourinOne runat="server" Controltype="menu" Display="v" />

For generating the menu, tree, panel or tab dynamically, the XML should be of the form:

XML
<Menu>
  <MainMenu Label="Registration" BaseURL="SearchCongress.aspx" MenuID="8"
    MainSecurity="AM" MenuSequence="1" ImageUrl="xp_documents.gif">
    <SubMenu Label="Search" URL="SearchCongress.aspx" MenuID="8"
      Security="AM" SubMenuID="9" SubMenuSequence="1" 
      ImageUrl="xp_documents.gif"/>
    <SubMenu Label="Add Company" URL="CompanyDetails.aspx" MenuID="8"  
      Security="A" SubMenuID="6" SubMenuSequence="4" 
      ImageUrl="xp_documents.gif"/>
    <SubMenu Label="New Order" URL="NewOrder.aspx" MenuID="8" Security="AM" 
      SubMenuID="7" SubMenuSequence="5" ImageUrl="xp_documents.gif"/>
  </MainMenu>
  <MainMenu Label="Maintenance" BaseURL="Congress.aspx" MenuID="6" 
    MainSecurity="A" MenuSequence="4" ImageUrl="xp_documents.gif">
    <SubMenu Label="Congress Type" URL="Congress.aspx" 
      MenuID="6" Security="A" SubMenuID="1" 
      SubMenuSequence="1" ImageUrl="xp_documents.gif"/>
    <SubMenu Label="Event Type" URL="EventType.aspx" MenuID="6" Security="A" 
      SubMenuID="2" SubMenuSequence="2" ImageUrl="xp_documents.gif"/>
    <SubMenu Label="Sales Type" URL="SalesType.aspx" MenuID="6" Security="A" 
      SubMenuID="3" SubMenuSequence="3" ImageUrl="xp_documents.gif"/>
    <SubMenu Label="Venue" URL="CongressVenue.aspx" MenuID="6" Security="A" 
      SubMenuID="4" SubMenuSequence="4" ImageUrl="xp_documents.gif"/>
    <SubMenu Label="Office" URL="Office.aspx" MenuID="6" Security="A" 
      SubMenuID="6" SubMenuSequence="6" ImageUrl="xp_documents.gif"/>
    <SubMenu Label="Sales Person" URL="SalesPerson.aspx" 
      MenuID="6" Security="A" SubMenuID="7" SubMenuSequence="7" 
      ImageUrl="xp_documents.gif"/>
    <SubMenu Label="Tax Rate" URL="TaxRate.aspx" MenuID="6" Security="A" 
      SubMenuID="8" SubMenuSequence="8" ImageUrl="xp_documents.gif"/>
    <SubMenu Label="User" URL="User.aspx" Security="A" MenuID="6" 
      SubMenuID="9" SubMenuSequence="9" ImageUrl="xp_documents.gif"/>
    <SubMenu Label="Option Type" MenuID="6" URL="PriceOption.aspx" 
      Security="A" SubMenuID="10" SubMenuSequence="10" 
      ImageUrl="xp_documents.gif"/>
  </MainMenu>
</Menu>

The MainSecurity attribute in the MainMenu node and the Security attribute in the SubMenu node are used to implement the security in displaying the menu items. To implement security in this control, keep the UserType in the session, for example (A for administrator), when the user logs on to the system. By comparing the value in session, the security is implemented.

C#
private bool isAuthorised(string sSecString, string sSecType)
{
  return(sSecString.IndexOf(sSecType)>=0);
}

The isAuthorized method returns true if the user is authorized to view that page, else it returns 0. For exmple, I have taken two users, Administrator (A) and Moderator (M). I have mentioned the pages that can be viewed only by the administrator as A and pages that can be viewed by both of them as AM. The menu can be configured using web.config.

XML
<add key="MenuXMLPath" value="/helper/" />
<add key="MainMenuFontColor" value="#ffffff" />
<add key="MainMenuShadowColor" value="#999999" />
<add key="MainMenubGColor" value="#000088" />
<add key="MainMenuMouseoverColor" value="#000088" />
<add key="SubmenuBgColor" value="#cfd3d8" />
<add key="SubmenuMouseoverColor" value="#ffffff" />
<add key="SubmenuBorderColor" value="#0000cc" />
<add key="SubmenuFontColor" value="#000000" />
<add key="SubmenuMouseOverFontColor" value="#000000" />
<add key="SubmenuShadowColor" value="#666666" />

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer TCS
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRe: Is 3 Levels Possible Pin
Venkat Eswaran31-Jan-05 17:39
Venkat Eswaran31-Jan-05 17:39 
GeneralRe: Is 3 Levels Possible Pin
Venkat Eswaran28-Feb-05 3:26
Venkat Eswaran28-Feb-05 3:26 
GeneralI get the following error Pin
Bryanpl30-Jan-05 8:55
Bryanpl30-Jan-05 8:55 
GeneralRe: I get the following error Pin
Venkat Eswaran31-Jan-05 17:40
Venkat Eswaran31-Jan-05 17:40 
GeneralCombo control Pin
Carlos R A de Oliveira30-Jan-05 7:50
Carlos R A de Oliveira30-Jan-05 7:50 
GeneralRe: Combo control Pin
Venkat Eswaran31-Jan-05 17:36
Venkat Eswaran31-Jan-05 17:36 
GeneralI got the following error.... Pin
viki G30-Jan-05 4:53
viki G30-Jan-05 4:53 
GeneralI got the following error :-( Pin
LuzErez29-Jan-05 4:22
LuzErez29-Jan-05 4:22 
GeneralRe: I got the following error :-( Pin
Venkat Eswaran30-Jan-05 2:16
Venkat Eswaran30-Jan-05 2:16 
GeneralVery Good Pin
Clickok28-Jan-05 5:18
Clickok28-Jan-05 5:18 
GeneralExcellent Article Pin
pchelp26-Jan-05 7:18
pchelp26-Jan-05 7:18 
GeneralRe: Excellent Article Pin
Venkat Eswaran26-Jan-05 17:19
Venkat Eswaran26-Jan-05 17:19 
GeneralExcellent Pin
pchelp26-Jan-05 7:15
pchelp26-Jan-05 7:15 
GeneralI need use Frame! Pin
Member 126857725-Dec-04 8:16
Member 126857725-Dec-04 8:16 
GeneralRe: I need use Frame! Pin
Venkat Eswaran26-Dec-04 2:24
Venkat Eswaran26-Dec-04 2:24 
GeneralRe: I need use Frame! Pin
Anonymous29-Dec-04 0:54
Anonymous29-Dec-04 0:54 
GeneralImbed Into project Pin
tlombard24-Dec-04 6:36
tlombard24-Dec-04 6:36 
GeneralRe: Imbed Into project Pin
Venkat Eswaran25-Dec-04 1:57
Venkat Eswaran25-Dec-04 1:57 
GeneralRe: Imbed Into project Pin
Venkat Eswaran25-Dec-04 2:13
Venkat Eswaran25-Dec-04 2:13 
QuestionToolbar? Pin
JasonBSteele20-Dec-04 22:32
JasonBSteele20-Dec-04 22:32 
AnswerRe: Toolbar? Pin
Venkat Eswaran20-Dec-04 23:43
Venkat Eswaran20-Dec-04 23:43 
GeneralRe: Toolbar? Pin
JasonBSteele20-Dec-04 23:52
JasonBSteele20-Dec-04 23:52 
GeneralLicensing information Pin
Georged20-Dec-04 17:18
Georged20-Dec-04 17:18 
GeneralRe: Licensing information Pin
bharathkumar20-Dec-04 19:50
bharathkumar20-Dec-04 19:50 
GeneralRe: Licensing information Pin
mikedepetris27-Dec-04 0:22
mikedepetris27-Dec-04 0:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.