CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > microsoft_downloads.css_friendly_control_adapters Tags:
Item Type: NewsGroup Date Entered: 10/6/2006 11:53:26 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 0 Views: 35 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
1 Items, 1 Pages 1 |< << Go >> >|
McGiv
Asp.Net User
Adding Menu CSS classe10/6/2006 11:53:26 AM

0/0

Hi,

 The first thing I noticed about this control was that it didn't include the Menu's CssClass property in the html. This means that all the Menu control are rendered the same. As I use a couple of Menu's on some pages and I need them to render differently I had to include the CssClass property. What I did was in the MenuAdapters was....

 

Replace the RenderBeginTag with the following - notice that I add a class variable controlCssClass.

  

string controlCssClass = null;
protected override void RenderBeginTag(HtmlTextWriter writer)
{
if (Extender.AdapterEnabled)
{
// add orig CSS class if (!string.IsNullOrEmpty(Control.CssClass))
{
controlCssClass = Control.CssClass + " ";

}

Extender.RenderBeginTag(writer, controlCssClass + "AspNet-Menu-" + Control.Orientation.ToString());

}
else { base.RenderBeginTag(writer);
}
}
 
 

 Replace BuildItems method with

 

private void BuildItems(MenuItemCollection items, bool isRoot, HtmlTextWriter writer)
{
if (items.Count > 0)
{
writer.WriteLine();

writer.WriteBeginTag("ul");
if (isRoot)
{
writer.WriteAttribute("class", controlCssClass + "AspNet-Menu");
}
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;

foreach (MenuItem item in items)
{
BuildItem(item, writer);
}

writer.Indent--;
writer.WriteLine();
writer.WriteEndTag("ul");
}
}

  

Replace GetItemClass with

  

private string GetItemClass(Menu menu, MenuItem item)
{
string value = "AspNet-Menu-NonLink";
if (item != null)
{
if (((item.Depth < menu.StaticDisplayLevels) && (menu.StaticItemTemplate != null)) ||
((item.Depth >= menu.StaticDisplayLevels) && (menu.DynamicItemTemplate != null)))
{
value = "AspNet-Menu-Template";
}
else if ((item.NavigateUrl.Length > 0) || item.Selectable)
{
value = "AspNet-Menu-Link";
}

if (item.Selected)
{
value += " AspNet-Menu-Selected";
}
else if (IsChildItemSelected(item))
{
value += " AspNet-Menu-ChildSelected";
}
else if (IsParentItemSelected(item))
{
value += " AspNet-Menu-ParentSelected";
}
}

// add control css class return controlCssClass + value;
}
 

 Replace the first few lines of BuildItem with

 

 

	private void BuildItem(MenuItem item, HtmlTextWriter writer)
{
Menu menu = Control as Menu;
if ((menu != null) && (item != null) && (writer != null))
{
writer.WriteLine();
writer.WriteBeginTag("li");
writer.WriteAttribute("class", controlCssClass + (item.ChildItems.Count > 0 ? "AspNet-Menu-WithChildren" : "AspNet-Menu-Leaf"));
writer.Write(HtmlTextWriter.TagRightChar);
writer.Indent++;
writer.WriteLine();
  

 

  


-------------------------------------

Damien McGivern

http://nimtug.org

-------------------------------------
1 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Beginning JavaServer Pages Authors: Vivek Chopra, Jon Eaves, Rupert Jones, Sing Li, John T. Bell, Pages: 1262, Published: 2005
Dreamweaver MX 2004: The Missing Manual Authors: David Sawyer McFarland, David Pogue, Pages: 836, Published: 2004
Visual Web Developer 2005 Express Edition For Dummies Authors: Alan Simpson, Pages: 358, Published: 2005
Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages Authors: Jacob J. Sanford, Pages: 474, Published: 2007
Macromedia Studio 8: Training from the Source Authors: Jeffrey Bardzell, Shaowen Bardzell, Bob Flynn, Pages: 543, Published: 2006
Beginning ASP.NET 3.5: In C# and VB Authors: Imar Spaanjaars, Pages: 734, Published: 2008
Special Edition Using Microsoft Office FrontPage 2003: Special Edition Authors: Jim Cheshire, Paul Colligan, Pages: 1080, Published: 2003
Beginning JavaScript with Dom Scripting and Ajax: From Novice to Professional Authors: Christian Heilmann, Pages: 485, Published: 2006
The Essential Guide to Dreamweaver CS3 with CSS, Ajax, and PHP Authors: David Powers, Pages: 784, Published: 2007
Dreamweaver CS3: The Missing Manual Authors: David Sawyer McFarland, Pages: 995, Published: 2007

Web:
CSS Classes Classes in Cascading Style Sheets or CSS makes it easier to create and maintain ... Then add class="menu" to the links you'd like different, like this: ...
Adding Menu CSS classe - ASP.NET Forums Adding Menu CSS classe. Last post 10-06-2006 7:53 AM by McGiv. 0 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
Joomla! v 1.5 How to use CSS class suffixes where to add css in joomla 1.5 · menu class suffix joomla ·




Search This Site:










a "web application project" for web-services ?

applying style sheet styles to master page

dnn 3.08 search input module settings unavailable

dnn 2.0.3 skinning issues

securing an app -- using location in the web.config

createuserwizard - continuedestinationpageurl

significance of buildsupport directory

dnn newb needs install guide (dnn site throwing errors)

requirements for sending mail

dnn3.2.2 search input bug?

simple image pathing solution

redirect users using windows authentication

delete network share file

need new isp that does db backups daily

appearance of an asp-menu's item

problem reinstalling visual studio 2005 professional

helper methods from aspx - why 'protected'??

module creation help

bug? dnn 3.1, friendly urls and url parameters

looking for portal creation wizard

asp.net 2.0 hard coded password recovery

name 'configurationsettings' is not declared.

stopping a master control from rendering

theme not working correct

error using the login control: cannot open user default database. login failed.

don't tell me the aspnet_wp.exe is recycled ...

when you delete a user from one portal, users with same username on other portals are also deleted!

wap for dotnetnuke

expand vertical menu - select vertical menu sub link - execute app - return menus are collapsed

role update email is a bit common...

 
All Times Are GMT