[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

Making a global back button in a web control

Dear Experts,

I'm trying to make a global 'back' button for my site.

I looked at this article, which seemed very useful (but is in c#)
http://codebetter.com/blogs/peter.van.ooijen/archive/2005/07/19/129384.aspx

I tried to convert it into VB.NET, but it's crashing every time I try to run it (included in my main project)

I'm getting a few warnings (overloads warnings), so that might have something to do with it. Can anybody suggest?

Thanks

NIck

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
<ToolboxData("<{0}:GlobalBack runat=server></{0}:GlobalBack>")> _
Public Class GlobalBack
    Inherits HyperLink
    Private Sub GlobalBack_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Me.NavigateUrl = Page.Request.UrlReferrer.AbsoluteUri
            Me.OnLoad(e)
        End If
    End Sub
    <Browsable(False)> Public Overloads Property NavigateUrl() As String
        Get
            Return Me.NavigateUrl
        End Get

        Set(ByVal Value As String)

            'nothing

        End Set
    End Property

End Class
0
nkewney
Asked:
nkewney
  • 2
  • 2
1 Solution
 
Bob LearnedCommented:
Try this:

<Browsable(False)> Public Overloads ReadOnly Property NavigateUrl() As String
        Get
            Return Me.NavigateUrl
        End Get
    End Property

Bob
0
 
nkewneyAuthor Commented:
Thanks Bob,

THis gives me

Error      57      Property 'NavigateUrl' is 'ReadOnly'.      D:\Projects\GLWebControls\GlobalBack.vb      13      13      GLWebControls

Thanks

Nick
0
 
Bob LearnedCommented:
Nick,

Here's the thing that I see, looking more closely:

1) Set the URL:
    MyBase.NavigateUrl = Page.Request.UrlReferrer.AbsoluteUri

2) Get the value:
   <Browsable(False)> Public Overloads ReadOnly Property NavigateUrl() As String
        Get
            Return MyBase.NavigateUrl
        End Get
    End Property

Bob
0
 
craskinCommented:
i don't really understand why making a web control to place on every page is easier than simply directing Request.UrlReferrer.AbsoluteUri to a button on each page?
0
 
nkewneyAuthor Commented:
Apologies for the delay in awarding the points.

Nick
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now