473,394 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

C# Web: How to vary hyperlink path depending on page

Hi guys, pretty new to C# and ASP.NET. Anyhow, I have a link that I would like to change depending on which set of data the user selects.

I basically want to set it up so that if the user is on page A, the link's going to point here and say this. If on page B, the link's going to point somewhere else and say something else.

I initially started using: Request.ServerVariables["SCRIPT_NAME"]
but that only gives you the filename, not the information about what data was selected (i.e. I need the full url path).

Anyhow, I switched to using "Request.UrlReferrer.AbsoluteUri.ToString()", but can't seem to get it to work either, as it keeps going to the default value. Am I just not putting the url in the right form? I have three different forms in the code, so I could eliminate some possibilities.

Any thoughts? Thanks in advance! :)


Expand|Select|Wrap|Line Numbers
  1. if(Request.UrlReferrer.AbsoluteUri != null)
  2. {
  3.     switch(Request.UrlReferrer.AbsoluteUri.ToString())
  4.     {
  5.         case "/TitleList.aspx":
  6.                 lnkto.NavigateUrl = "http://dev.xxxxxx.com/TitleList.aspx?searchType=5&CategoryPrefer=movies&searchText=&category=New%20Movie%20Arrivals";
  7.                 lblto.Text = "View Silly Movies";
  8.                 break;
  9.         case "/TitleList.aspx?searchType=3&searchText=&CategoryID=1170&Category=Featured%20Content":
  10.                 lnkto.NavigateUrl = "http://dev.xxxxxx.com/TitleList.aspx?searchType=6&searchText=&CategoryPrefer=tv&category=New%20TV%20Arrivals";
  11.                 lblto.Text = "View All TV";
  12.                 break;
  13.         case "http://dev.xxxxxx.com/TitleList.aspx?searchType=7&searchText=&CategoryID=1180&Category=Featured%20Content":
  14.                 lnkto.NavigateUrl ="http://dev.xxxxxx.com/TitleList.aspx?searchType=7&searchText=&CategoryPrefer=tv&category=All";
  15.                 lblto.Text = "View All Trailers";
  16.                 break;
  17.         default: lnkto.NavigateUrl ="http://dev.xxxxxx.com/TitleList.aspx?searchType=7&searchText=&CategoryPrefer=tv&category=All";
  18.                 lblto.Text = "View All Content";
  19.                 break;
  20.     }
  21.  
  22. }
  23.  
Jan 12 '08 #1
1 1112
OK, I realized that all that above was wrong, I needed to be using:

Request.ServerVariables["QUERY_STRING"]

I have another question about something in the new if statement, but it's better described in a new thread, so this can be considered closed.
Jan 12 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: laura | last post by:
I am writing an intranet and want to be able to hyperlink to all files within a specific folder AND it's subfolders. Whilst I can hyperlink to the files in the specified folder AND I can also...
7
by: Johnny | last post by:
How do I create a link on a Web page on my hard drive that will run an executable file on my hard drive? For example, let's say I create runpoodle.htm and save it to my hard drive, and let's...
1
by: Amil | last post by:
I have a page with a hyperlink (actually in a datalist). I want the URL to do a postback essentially. I tried to use Page.Request in the NavigateUrl, but it's always empty? How do I tell it to...
1
by: news.microsoft.com | last post by:
Hello and first of all thank you for your time. I am currently developing an ASP.net web page, which has data stored in SQL Server. It is a web page for a State Agent and my problem is: I need...
31
by: Yeah | last post by:
Is it absolutely necessary to include "http://" in an A HREF hyperlink? Would it be wise to remove this from one's Links page, just to save code?
7
by: ThunderMusic | last post by:
Hi, Ok, I find myself having a lot of troubles with URL Rewriting and I've seen on the net that in some situations, indexers have difficulty indexing sites because of some flaws in the url...
7
by: pb | last post by:
Hi all, I have some code that automatically generates a url depending on user selections. This url is then set as a hyperlink and the user clicks on the link that has the target as an iframe on...
20
by: tshad | last post by:
I had posted this problem earlier and just noticed that the Hyperlink is the problem. Apparently, it doesn't figure out the path correctly. It uses the path of the file it is in, even if it is...
10
by: sierra7 | last post by:
I'm trying to create a form where a user enters a document reference number and then clicks a command button to add a hyperlink to the document, via a file picker. Thanks to Adezii's excellent...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.