Url / Page Greeting?

Discussion in 'ASP .Net' started by Leon, Dec 3, 2004.

  1. Leon

    Leon Guest

    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
     
    Leon, Dec 3, 2004
    #1
    1. Advertising

  2. Leon

    Patrice Guest

    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

    --

    "Leon" <> a écrit dans le message de
    news:%...
    > 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
    >
    >
     
    Patrice, Dec 3, 2004
    #2
    1. Advertising

  3. Leon

    Leon Guest

    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

    "Patrice" <> wrote in message
    news:...
    > 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
    >
    > --
    >
    > "Leon" <> a écrit dans le message de
    > news:%...
    >> 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
    >>
    >>

    >
    >
     
    Leon, Dec 3, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthias S.
    Replies:
    1
    Views:
    433
    OHM \( Terry Burns \)
    Mar 27, 2005
  2. Sharon
    Replies:
    6
    Views:
    454
    Sharon
    Jan 3, 2004
  3. tak
    Replies:
    0
    Views:
    516
  4. Saeed Amrollahi

    The greeting code in Java

    Saeed Amrollahi, Jun 19, 2011, in forum: Java
    Replies:
    48
    Views:
    2,050
  5. Saeed Amrollahi

    The greeting code in Java

    Saeed Amrollahi, Jun 19, 2011, in forum: Java
    Replies:
    15
    Views:
    873
    Arne Vajhøj
    Jul 24, 2011
Loading...

Share This Page