Re: How do I do these dynamic links in ASP.NET ?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Karl Seguin (_at_)
Date: 01/31/05


Date: Mon, 31 Jan 2005 13:01:03 -0500

Alan:
The community starter kit has a well-setup breadcrump component (but it's
database driven). You might want to check it out.

The way I've always seen it set up is via a user control which you include
atop each of your page. The user control would then be fed off an XML file
or Database where it would use the current page to figure out what
breadcrumb to build. This is more elegant than the MakeLink "xxx", "yyy"
solution because it makes the user control totally self-sufficient as well
as making it easily modifiable via an XML file (as oppsed to having to
hard-code the links on each page)

You can also get free controls to do this for you:
http://www.loudcarrot.com/webcontrols/navpath.aspx

Normally it's done simply by reading data into some type of collection (say
an arraylist) and binding that to a datagrid...

Karl

-- 
MY ASP.Net tutorials
http://www.openmymind.net/
"Alan Silver" <alan-silver@nospam.thanx> wrote in message
news:IawZTDL9Vl$BFw3r@nospamthankyou.spam...
> Hello,
>
> I Classic ASP, I used to have a standard way of making the top-level
> site navigation links. I had an include file which included a Sub like
> this ...
>
> Sub MakeLink(TocURL, TocText)
>   If TocURL = ThisURL Then
>     Response.Write("<br>" & TocText)
>   Else
>     Response.Write("<br>" & TocText & "")
>   End If
> End Sub
>
> (air code, so ignore typos), where ThisURL had been set to the URL of
> the current page. I could then do something like ...
>
> MakeLink "/", "Home"
> MakeLink "/contact.asp", "Contact Us"
>
> and so on. This include file could then create a set of links for every
> page.
>
> Now, how do I achieve the same end in ASP.NET? I guess I could have a
> label in the place where I want the links to be, then have a sub in the
> Page_Load event that builds a string containing the HTML. At the end of
> the sub, the label.Text could be set to the string.
>
> This seems a little inelegant considering the way ASP.NET is set up to
> allow structured coding. Does anyone have a better suggestion for this?
>
> TIA
>
> -- 
> Alan Silver
> (anything added below this line is nothing to do with me)


Relevant Pages

  • public shared object... and disappearing xml content in file
    ... It is created from an xml file stored on disk. ... Public Sub New ... Private Sub Button1_Click(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Failed to load viewstate - user controls
    ... Private Sub Page_Load(ByVal sender As System.Object, ... Dim r As New TableRow ... Dim c As TableCell ... The problem is when I navigate from one type of user control ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: child controls inside a user control inside a datalist
    ... you're not getting references to the controls inside your user control. ... End Sub ... (ByVal sender As Object, ByVal e As _ ... > Protected WithEvents cmbDdl As System.Web.UI.WebControls.DropDownList ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: More Custom Command button problems
    ... rather than try to manipulate them directly: ... public sub SetVisibleButton(byval intButtonIndex as integer, ... > I have created a user control to display a custom command button. ... > determine which of the bitmaps are visible ...
    (microsoft.public.vb.general.discussion)
  • Please help with handling events in a tabstrip/multipage/user control environment
    ... Private Sub btnSubmitSearchPrefs_Click(ByVal sender As System.Object, ... I have also added the event in the class definition of my user control: ... Protected WithEvents SearchFields As SearchFields ... I also added a handler in the aspx file for the event which SHOULD be raised ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)