The following code will give any page the ability to be used as an rss feed automatically

[code lang=”csharp”]
Public class BasePage : System.Web.UI.Page
{
protected override void Render(HtmlTextWriter writer)
{
if (Request.QueryString["rss"] == "true")
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.IO.StringWriter sw = new System.IO.StringWriter(sb);
HtmlTextWriter nw = new HtmlTextWriter(sw);
Response.Clear();
writer.Write("");
writer.Write("");
writer.Write(" ");
writer.Write(" " + this.Request.Url.AbsoluteUri.ToString() + "");
writer.Write(" ");
writer.Write(" en-us");
writer.Write(" " + DateTime.Now.ToUniversalTime().ToString() + "");
writer.Write(" " + DateTime.Now.ToUniversalTime().ToString() + "");
writer.Write(" ");
writer.Write(" Dynamic page generator");

writer.Write(" ");writer.Write(" " + this.Request.Url.AbsoluteUri.ToString() + "");
writer.Write(" ");
RenderChildren(nw);
if (sb.ToString().IndexOf(" ") > 0)
writer.Write(Util.StripHTML(sb.ToString().Substring(sb.ToString().IndexOf(""))));
else
writer.Write(Util.StripHTML(sb.ToString()));
writer.Write("");
writer.Write(" " + DateTime.Now.ToUniversalTime().ToString() + "");
Guid g = new Guid();
writer.Write(" " + g.ToString() + "");
writer.Write(" ");writer.Write(" ");
}
else
{
base.Render(writer);
}
}

}
public static class Util
{
public static string StripHTML(string htmlString)
{
string pattern = @"<(.\n)*?>";
return Regex.Replace(htmlString.Replace(" ", " "), pattern, string.Empty);
}
}
[/code]

So I tend to use Dotnetnuke alot for my side projects and its just generaly a good portal. But the default solpartmenu was always a creative challange making it look good. And the Asp.net menu provider seems to have a lot of code in it. So i looked around and saw some free menus, but they where always quirky… and when i used reflector on them i could see why. 

Which led to this posting. As you can see my code is always very simple, i hate re inventing the wheel. What this control is doing is populating the menuitemcollection.

[code lang=”csharp”]
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
namespace QuickMax.UI
{
public class DnnAspNetMenu : System.Web.UI.WebControls.Menu
{
DotNetNuke.Entities.Modules.PortalModuleBase _DnnBase;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
_DnnBase = new DotNetNuke.Entities.Modules.PortalModuleBase();
foreach (DotNetNuke.Entities.Tabs.TabInfo tab in _DnnBase.PortalSettings.DesktopTabs)
{
if (tab.IsVisible && tab.Level == 0)
{
bool badd = false;
foreach (DotNetNuke.Security.Permissions.TabPermissionInfo tbi in tab.TabPermissions)
if (_DnnBase.UserInfo.IsInRole(tbi.RoleName))
badd = true;
if (badd)
{
MenuItem mnuItem = new MenuItem();
mnuItem.Text = tab.TabName;
mnuItem.NavigateUrl = tab.FullUrl;

mnuItem.Selected = tab.TabID.Equals(_DnnBase.PortalSettings.ActiveTab.TabID);FillChildren(ref mnuItem, tab);
this.Items.Add(mnuItem);
}
}
}
}
private void FillChildren(ref MenuItem mnuitem, DotNetNuke.Entities.Tabs.TabInfo parent)
{
foreach (DotNetNuke.Entities.Tabs.TabInfo tab in _DnnBase.PortalSettings.DesktopTabs)
{
if (parent.TabID == tab.ParentId)
{
bool badd = false;
foreach (DotNetNuke.Security.Permissions.TabPermissionInfo tbi in tab.TabPermissions)
if (_DnnBase.UserInfo.IsInRole(tbi.RoleName))
badd = true;
if (badd)
{
MenuItem mnuItem = new MenuItem();
mnuItem.Text = tab.TabName;
mnuItem.NavigateUrl = tab.FullUrl;

mnuItem.Selected = tab.TabID.Equals(_DnnBase.PortalSettings.ActiveTab.TabID);FillChildren(ref mnuItem, tab);
mnuitem.ChildItems.Add(mnuItem);
}
}
}
}
}
}
[/code]