Link to home
Create AccountLog in
Avatar of PrimeNY
PrimeNY

asked on

I need to grab the entire URL

I have a page with this URL:
buyer.aspx#start

How can I grab the whole URL including the "#start" part.

This:  TextBox1.Text = Request.Url.AbsolutePath
gives me only "buyer.aspx" without the "#start".
Avatar of ZachSmith
ZachSmith
Flag of United States of America image

#start is a client side anchor. #start is actually not sent to the server.. So, you will probably have to use JavaScript to populate a hidden variable using something like document.location and then retrieve that hidden variable in your code behind.
I don't believe that value is passed to the server as it's used by the browser to find specific portions of the page.  Is there any reason you can't use a query string instead?
Avatar of PrimeNY
PrimeNY

ASKER

OK now I understand that the server wont recognize that part of the URL.  So I'm assuming I'm going about what I'm trying to accomplish incorrectly.  This is what I'm trying to accomplish.  
A user clicks on a linkbutton in my web page "buyer.aspx":
 Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
        ID = Request.QueryString("BusNum")
        If ID = "" Then
            TextBox1.Visible = True
            LinkButton2.Visible = True
            LinkButton1.Visible = False
         End If
    End Sub  
Problem is that this returns the page to the top where the user can't see the changes to the page because they are on the bottom of the page.

I was trying to use:
<A NAME="start">Let's Get Started...</A>
tag within the page and then use "#start" within the URL to force the page load to the bottom but I need to be able to capture the "#start" part of the URL.  I'm sure there is a better way to accomplish what I'm trying to do.
ASKER CERTIFIED SOLUTION
Avatar of ZachSmith
ZachSmith
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of PrimeNY

ASKER

That's it.  Thanks.  I knew there must have been an easier way.