Blue Theme Orange Theme Green Theme Red Theme
 
Nevron Chart
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Nevron Chart
Search :       Advanced Search »
Home » ASP.NET & Web Forms » Dynamic Mouse Over Dual Tab Menu

Dynamic Mouse Over Dual Tab Menu

This article is designed to give you quick information to create dynamic mouse over dual tab menu.

Page Views : 4774
Downloads : 151
Rating :
 Rate it
Level : Beginner
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
DemoSolution.zip
 
 
DevExpress Free UI Controls
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 


Purpose: 

This article is designed to give you quick information to create dynamic mouse over dual tab menu.

Intended Audience:

This guidance is intended for ASP.Net web developers. 

Technology: 

ASP.Net

Reference Name: 

http://www.dynamicdrive.com

Requirement Scenario: 

To create a consistent, easily managed navigation solution for site, you can use tab menu navigation. Tab menu navigation offers the following features:

It provides a consistent way for users to navigate site. As your site grows, and as you move pages around in the site, it can become difficult to manage all of the links. Tab menu navigation enables you to store URL to all of your pages in a central location called sitemap. 

You can use a site map to describe the logical structure of your site. You can then manage page navigation by modifying the site map as pages are added or removed, instead of modifying hyperlinks in all of your Web pages.

This control displays an expandable menu that users can traverse to get to different pages in your site. A node that contains child nodes is expanded when the cursor hovers over the menu.

Work Scope in the Project 

You can modify design of this control by changing CSS files and also can add n number of tabs and its sub menu by doing entry of tags in XML file.
Solution Identified and Provided: 

This is a mouse over tabs menu. Move the mouse over designated links, and additional sub menu contents appear in a separate block. It as an inline two level menu. You can specify name of main tab and sum menu with respective link in XML file, plus whether the sub menu contents should disappear when the mouse rolls out of that area.

You can easily toggle between a two level tabs menu. For the later, the entire a second level is hidden, allowing you to use script simply as tab links.

For this tab controls you need to create user controls because it's a reusable controls. A user control follows the same structure as a Web form, except that such controls are derived from the System.Web.UI.UserControl class, and are stored in ASCX files. Like ASPX files, an ASCX file contains static HTML or XHTML markup, as well as markup defining web control and other user controls. 

Steps for Implementation: 

Step 1: Create home.aspx page and register tab control on page.

<%@ Register TagPrefix="uc1" TagName="ucTabStrip" Src="myTab.ascx" %>

Step 2: Add tag in home.aspx page.

<uc1:ucTabStrip id="tab1" runat="server" ></uc1:ucTabStrip>

Step 3: Add user control in solution and rename it to "myTab.ascx"

Step 4: Write below code in source part of myTab.ascx

<script type="text/javascript" language="javascript" src="myFunctions.js"></script>
<link href="tabStyle.css" rel="stylesheet" type="text/css" />
<table runat="server" id="table1" ></table>

Step 5: Add following files in solution.

1.myFunction.js
2.tabStyle.css 
3.myXML.xml

Step 6: Write below function  in myTab.ascx.cs and call it in page load.

/// <summary>
function will fetch elements of main tabs and sub tabs from xml and create the controls dynamically
/// </summary>

        public void createTabControl()
        {
            //variable declaration
            int i = 0;
            string id, pnId, value;
            //datset object for retriving data in table from XML
            ds = new DataSet();
            //reading of xml file and converted it into dataset
            ds.ReadXml(Server.MapPath("myXML.xml"));
            //getting count of maintabs
            n = ds.Tables[1].Rows.Count;
            //creating reference of n panel and cells for tabs
            pn = new Panel[n];
            tc = new HtmlTableCell[n];
            tr = new HtmlTableRow();
            //creating array for Panel ID
            arrId = new String[n];
            //creating n panels
            for (int cc = 0; cc < n; cc++)
                pn[cc] = new Panel();
            //iterate rows for creating tabs and sub tabs
            foreach (DataRow r in ds.Tables[1].Rows) 
            {
                arrId[i] = r[1].ToString();
                tc[i] = new HtmlTableCell();
                id = r[0].ToString();
                value = r[1].ToString();
                pnId = r[1].ToString();
                pn[i].Attributes.Add("class", "Panelstyle");
                pn[i].Attributes.Add("id", pnId);
                pn[i].Attributes.Add("onmouseout", "panelonMouseOut('" + id + "','" + pnId + "'," + n + ")");
                pn[i].Attributes.Add("onmouseover", "panelonMouseOver('" + id+ "','" + pnId + "'," + n + ")");
                a = new HtmlAnchor();
                a.Attributes.Add("id", id);
                a.Attributes.Add("onmouseout", "btnMouseOut('" + id + "','" + pnId + "'," + n + ")");
                a.Attributes.Add("onmouseover", "btnOnclick('" + id + "','" +pnId + "'," + n + ")");
                a.Attributes.Add("class","mainmenu");
                a.InnerText = r[1].ToString();
                a.HRef = r[2].ToString();
                tc[i].Controls.Add(a);
                this.Controls.Add(pn[i]);
                tr.Controls.Add(tc[i]);

                //creating for subtabs
                foreach (DataRow rr in ds.Tables[3].Rows)
                {
                    if(rr[1].ToString()==r[0].ToString())
                    {
                        a = new HtmlAnchor();
                        a.InnerText = rr[2].ToString();
                        a.Attributes.Add("class", "submenu");
                        a.HRef = rr[3].ToString();
                        pn[i].Controls.Add(a);
                    }
                }
                i = i + 1;
            }
            //declaring global array of panel id to refer in javascript
            for (int m = 0; m < arrId.Length; m++)
                this.Page.ClientScript.RegisterArrayDeclaration("arrId", arrId[m]);
            //add block of tabs in table
            table1.Controls.Add(tr);
        }

Is this the Work Around or Best Solution?

Can this solution be improved: Yes the code and be improved or instead of running the batch file we can execute all the processes using DOT NET coding.

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Uday Gaikwad
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the Top 5 .NET Memory Management Fundamentals
To write the best .NET code, you need to know exactly how the .NET framework really manages memory. Ricky Leeks presents the Top 5 fundamental facts of .NET memory management. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
 Comments

 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.