No client-side scripting, well that makes life a little simpler for
you, though a little harder on ther user and the server. Also tough
on the real estate, but requirements are requirements.
The user control is a good choice.
My first tempation would be to do this with xml/xslt. Xml file would
contain the menu structure, xslt would transform it into links.
Something like this...
XML File with Menu Items, Notice that items can contain items, so you
can make this any level
<?xml version="1.0" encoding="utf-8" ?>
<menu>
<item ID="1" Text="Home" Url="Home.aspx"></item>
<item ID="2" Text="Cool Stuff" Url="coolstuff.aspx">
<item ID="3" Text="Alien Bodies" Url="ab.aspx" />
<item ID="4" Text="Perpetual Motion" Url="pm.aspx" />
</item>
<item ID="5" Text="Links" Url="Links.aspx"></item>
</menu>
XSLT file, XSLT and Recursion make for very simple coding
Probably want to style the selected item to stand out, but I'll leave
that as an excercise for the reader.
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="CurrentItemID">4</xsl:param>
<xsl:template match="/">
<table>
<xsl:for-each select="menu/item">
<xsl:call-template name="Item" />
</xsl:for-each>
</table>
</xsl:template>
<!-- display our item in its own row -->
<xsl:template name="Item">
<tr>
<td>
<a href="[EMAIL PROTECTED]@ID}"><xsl:value-of
select="@Text" /></a>
<!-- only display children if the current link
is a child or has
children -->
<xsl:if test="descendant-or-self::[EMAIL
PROTECTED]">
<table>
<xsl:for-each select="item">
<xsl:call-template name="Item"
/>
</xsl:for-each>
</table>
</xsl:if>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
User control is very simple (Cstuff is my namespace, will need to
change for your project)...
<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="SSMenu.ascx.cs" Inherits="CStuff.SSMenu"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<asp:Xml id="xmlMain" runat="server" DocumentSource="xml/Menu.xml"
TransformSource="xml/Menu.xslt"></asp:Xml>
Code behind for the control...
public class SSMenu : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.Xml xmlMain;
private void Page_Load(object sender, System.EventArgs e)
{
// pass ID to stylesheet if provided
if(Request.QueryString["ID"] != null)
{
XsltArgumentList args = new XsltArgumentList();
args.AddParam("CurrentItemID","",
Request.QueryString["ID"]);
xmlMain.TransformArgumentList = args;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web
Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not
modify
/// the contents of this method with the code
editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
Basic, server side menu.
On 10/4/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi gurus
>
> I am urgently seeking an expanding menu written in server side code, ie all
> the ones I have been recommended are using dhtml but because of accessibility
> issues I am not allowed to use any type of client side scripting. I need to
> use this as a user control for a .net website I am putting together. Can
> anybody point me in the right direction?
>
> Thanks in advance
> Cal
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
--
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/