Retrieving user control file name

  • Thread starter Bjørn Toft Madsen
  • Start date
B

Bjørn Toft Madsen

Hi all,

We have a user control base class (inheriting from
System.Web.UI.UserControl) that provides localization support and some
other often used UserControl methods. We are basing all our user
controls on this base control.

We need to retrieve the file name of the user control in this base
class, like this

'in fileX.ascx
Public MustInherit Class NSUserControl
inherits System.Web.UI.UserControl

public function GetActualFilename() As String
'...
end function

public sub DoSomeLocalization
'dim filename as String = GetActualFilename()
end sub
End Class

'in fileY.ascx
Public Class AnotherUserControl
inhertis NSUserControl

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load

DoSomeLocalization()
end sub
End Class

Now when AnotherUserControl initializes, it should run
DoSomeLocalization() and the filename variable in this sub should be
set to fileY.ascx, not fileX.ascx.

It is no problem retrieving what the containing page's actual filename
is, but is there a way to do the same for UserControls`? (btw:
Obviously this scheme is possible by declaring GetActualFilename to
MustOverride and then hardcoding the filename of the user control in
inheriting classes in override, but for a bunch of reasons this is not
what we are looking for).

Basically what we are looking for is a simple function, like...
System.Web.UI.UserControl.Path()

.... just like there is a
System.Web.UI.Page.Request.Path()

Thanks for any help provided.
regards
Bjorn Toft Madsen
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top