Url / Page Greeting?

L

Leon

I have 10 .aspx pages within my web application and would like to know what
is the best way I can write code within my header user control so that the
greeting message change for each page the user are currently viewing
("should I do an if/else or case statement within my header user control?")?
how?

Also what is the best way to know exactly what page the current user are
viewing ("using the full url such as www.mysite.com/home.aspx or is it a
shorthand way?")?

Example:
Page = www.mysite.com/home.aspx
Greeting.Text = Welcome to mysite.com
 
P

Patrice

Instead of hardcoding this into the control you could just have whatever
kind of data structure you prefer that associates the current path with the
corresponding message (possibly read from a DB or a text file or whatever)
and even a default mesage if you don't find an entry for a particular page.

You can get the path for the current request by using Request.FilePat (will
show /home.aspx).

Patrice
 
L

Leon

what I just expose a public variable within the user control like the
following, do you this this is the best way to go?
Example:
*Header.ascx - user control
Public Greeting As String

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

lblGreeting.Text = Greeting

End Sub
-----------------------------------------------------------------------------------------------------------------------------------------------------
*Home.aspx.vb - code behind class

Public ctlHeader As Header

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

Me.ctlHeader.Greeting = "Welcome To MySite.Com"

End Sub
 

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,056
Latest member
GlycogenSupporthealth

Latest Threads

Top