Solved

Hide or display label ot object based on url values

Posted on 2013-06-28
4
318 Views
Last Modified: 2013-06-28
I am trying to display a label on the Login.aspx page based on the access denied values that are produces when a user clicks a links to a page that requires a login. My code is below.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        If Request.QueryString("ReturnUrl").ToString() = "%2fefitnessplanner_dev%2fworkouts_saved.aspx" Then

 Label1.Visible = True

        Else : Label1.Visible = False

        End If

    End Sub

Admiitedly I have not done much code writing on this project so I am not sure if the code is accurate. I do not get a compile/build error. The problem is the label displays regardless of what link I click. Is my syntax right. Should I write it another way. The following is the entire url return value:

http://localhost/efitnessplanner_dev/(S(13hshoxd1kfnomtl2ldfn5kg))/login.aspx?ReturnUrl=%2fefitnessplanner_dev%2fworkouts_saved.aspx

If I can get past this hurdle it will help me with this project greatly. Thanks for your help in advance.
0
Comment
Question by:derrekdeveloper
  • 3
4 Comments
 

Author Comment

by:derrekdeveloper
ID: 39284937
I have also tried this approach with contains in the code. The label still displays when it should not:

 If Request.QueryString("ReturnUrl").Contains("%2fefitnessplanner_dev%2fworkouts_saved.aspx") Then

            Label1.Visible = True

        Else : Label1.Visible = False



        End If

    End Sub
0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39285680
The contents of the QueryString you're testing against are decoded automatically. So the contents in this case would be "/efitnessplanner_dev/workouts_saved.aspx".
0
 

Author Comment

by:derrekdeveloper
ID: 39285753
This is great! Solved the issue immediately!!! Thank you.
0
 

Author Closing Comment

by:derrekdeveloper
ID: 39285757
Solved the issue immediately! Worked great!!!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now