Extracting the current URL from "Design View"

R

RSH

Hi,

I have a user created control that has quite a bit of codebehind code. I
have one link in the HTML page code that I need to insert the current URL
in. I have tried several scenerios but the URL always comes back with
nothing:

href="EmployerSolutions_Quote.aspx?url=<% Request.Url.ToString %>" Click
here for our
comprehensive Quote...

I need to pass the current URL to the next page so after they fill out the
quote they are returned to the page they came from. Since the control
appears throughout the site it can't be hardcoded.

How do I make that work?

Thanks!
Ron
 
T

Tim_Mac

hi Ron,
you could do it that way. but there is always the Url.Referrer property.
note that it gets lost if you do a postback on your
EmployerSolutions_Quote.aspx page. the Referrer is itself after a postback,
if you follow. i use a base page class in most of my projects, which
persists the UrlReferrer across postbacks, so that it isn't necessary to
pass URLs around the site the whole time.

also, it might be no harm to use the explicit full URL:
Request.Url.AbsoluteUri

Request.Url.ToString() seems to give the absolute url anyway, but remember
Request.Url is only an object, and calling .ToString() on an object will
usually just give you the type name of the object.

ahhh, i just noticed, the problem is that you didn't include the = sign in
your <% code blocks.
you should have <%= Request.Url... %>

the way you have it just means that the expression is evaluated, not
outputted to the client.

hope this helps

tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top