473,795 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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><a href=""" & TocURL & """>" & TocText & "</a>")
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)
Nov 19 '05
12 1866
Alan:
ASP.Net probably won't care, but VS.Net might not like it very much. An
alternative you might not have considered is to use master pages for the
common functionality:

http://www.metabuilders.com/Tools/MasterPages.aspx

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Alan Silver" <al*********@no spam.thanx> wrote in message
news:tk******** ******@nospamth ankyou.spam...
Phil,
Wow, looks like the community portal has really changed since last I lookedat it. I don't remember it being a server control, but you can find theirbreadcrumb in
Engine\Framewo rk\Sections\Con trols\BreadCrum b.cs.


Thanks, now I know where to look ;-)
The problem is that unless you are familiar with how the sections work,
you'll be a little loss.


A "little"? Try a lot!! There are so many files there, it's hard to know
where to start.
The free control that I pointed you to has free source code, so again, youmight wannat ake a look at it.


Thanks, I did take a look. I didn't realise at first that they included
source code. That changes things as I can now learn from them.
As for your question about the <head></head>...it isn't true that
server/user controls must be placed inside <form></form> Some controls,
namely those which participate in viewstates must. So if your user/server
control has a textbox, linkbutton, button, ... then yes it must be in a
<form></form>...if you are only rendering HTML such as <head>, <title> and<meta> you should be ok


I realised this last night when I remembered using a Literal control to
set the <title> of a page. It occurred to me that this wasn't in a form.

OK, so let me phrase the question slightly differently then. In Classic
ASP, I used to create an include file that had part of the <head>
(common bits like some META tags, the link to the stylesheet and so on),
the closing </head> tag, the opening <body> tag, and the parts of the
HTML that were common to all pages (which usually included the
navigational links).

In ASP.NET, I think this might be a problem. My current understanding is
that the best way to do the common code part is to put it in a custom
control, and use that control on the page. The problem would be that the
main page would not have the </head> and <body> tags in it. Wouldn't the
ASP.NET engine take an exception (no pun intended) to that? From what I
have seen (haven't got it clear enough yet), it likes to generate some
of these bits itself. Am I wrong here? Please clarify.

Thanks

--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #11
>You could place the DataSet in Cache. If you are pulling from an xml file,
you could place a File Dependency to the xml file driving your cached
DataSet.
That's clever. Caching is a new one on me (as is everything at the
moment!!). I had a brief look at the pages below, and the second one
seems to have what I need, although I think it will need some careful
reading before I feel confident enough to use it.

However, it does mean that I can get on with looking at using an XML
file for the data and not worrying about killing the server. When I've
got the basic functionality working, I can then look at caching the data
to improve performance.

Thanks for the info and links.
If it is coming from the a database, you could still cache it. 2.0 will
have a database cache feature built in, but there are some samples out there
for database cache dependency in 1.1

I couldn't find the link I used to write mine, but here are some MSDN links:

http://msdn.microsoft.com/msdnmag/is...04/WickedCode/

http://msdn.microsoft.com/msdnmag/is...e/default.aspx

bill

"Alan Silver" <al*********@no spam.thanx> wrote in message
news:n0******* *******@nospamt hankyou.spam...
>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.


It occurred to me last night, won't this mean that *every* single page
request will involve a file read or database query? If so, won't that
have a serious performance impact? I know my original suggestion of
having the links inside the custom control doesn't have the flexibility
of the XML file, but it would be very fast.

Any comments?

--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #12
>Alan:
ASP.Net probably won't care, but VS.Net might not like it very much. An
alternative you might not have considered is to use master pages for the
common functionality:

http://www.metabuilders.com/Tools/MasterPages.aspx


Karl,

Thanks for the link. I think I'm suffering from information overload at
the moment!! I had a look at that page, but I think it needs printing
out and reading carefully.

I'm going to have a go at the XML file approach first as that looks very
promising. I might come back to the master pages stuff later.

Thanx again

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1871
by: Glenn | last post by:
Dynamic help topic links show properly and search brings up links, but when any link is clicked I receive a "Page Cannot be displayed message in the Explorer window and the title bar of Visual Studio reports that it cannot find server. What server is this? The start page works fine going to the internet and my normal Internet Explorer is working fine. VS 2003 v. 7.1.3044 Framework v. 1.1.4322 -- Thanks for any help, suggestions before...
5
3326
by: Sally B. | last post by:
Hello, I searched, but couldn't find answers--probably because I'm not sure what this is called... Anyway, I have about 50 web pages and I want to have some JavaScript that will read in a list of keywords, scan the web page and create links on any of those keywords... Is there any way to do this sort of thing? Thanks!
3
1612
by: Chad THomas | last post by:
I have a data repeater controll on a page. in each row that is displayed, I would like to have an action column that has differnet links shown depending on certain criteria from the database. In traditional asp you could check the value as you looped through the recordset, but in asp.net I am not sure how to do it if you are binding to a control. Thanks, Chad
8
2257
by: Sandy Pittendrigh | last post by:
I have a how-to-do-it manual like site, related to fishing. I want to add a new interactive question/comment feature to each instructional page on the site. I want (registered) users to be able to add comments at the bottom of each page, similar to the way the php, mysql, apache manuals work. PUNCHLINE_A:
1
5532
by: nsvmani | last post by:
Hi, i am trying to get the FileOpen dialogue window as soon as clicked href link I am using IE6 with ActiveX enabled. Just need to get the File Open dialogue window when i click on the HREF links.It would be great , if i know how to create the dynamic HREF links like it should be getting different document based on each userid. Here is my part of jsp code for your reference: <%@ page...
3
2768
by: Peter K | last post by:
Hi I need to make a list of "download file links" on a webpage. All the data is dynamic - it depends on the user's actions how many files, and which files, I need to present in the list. The files are identified by an id in a database. How do I do this? I was thinking I could somehow make a list of <a href...> tags which could call a method in my c# code-behind. Is this possible? Or is there a better way?
9
2986
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I got the core of the javascript from here: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm I noticed in the demo that sometimes the content takes a long
12
9510
by: Lazoris | last post by:
OK heres a newb question and I'm sorry for it, but im getting back into web design after like 5 years off and im stuck even though i should know the problem i cant seem to correct it atm. What I'm trying to do is create a page that pulls up a list of items in a DB page, lists the items and creates a dynamic link using the item_id making the item_name a link to a more detailed page. So that when they click the Item_name it uses the item_id...
2
1459
by: ibec | last post by:
Hi I'm new to the forum and MySQL and PHP. I hope you'll excuse the simple question. Here's my problem: On our website I'm trying to put together a dynamic collection of links that will be presented on one page. For the database table, I've created the following columns: id, category, link_name, http, description My problem is that when I present the links, I want to group them by their category and have the category name as the section...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.