473,395 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Url / Page Greeting?

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
Nov 16 '05 #1
4 1315
You could develop a UserControl that exposed a public property such as
GreetingText. When embedding the UserControl on the different physical aspx
pages, you could simply set the getting text by assigning it to the
attribute of the server side control tag.

<CustomerName:GreetingDisplay id="ctrl" runat="server" GreetingText="Here's
ny custom greeting text" />

This is the simple version. You could change the parsing of child controls
for the UserControl, allowing for more customization - e.g. by allowing HTML
content within the opening and closing tags of the server side control tag.

<CustomerName:GreetingDisplay id="ctrl" runat="server">
<div>
<b>Welcome!</b> <br />
<div>Some other text ..</div>
</div>
</CustomerName:GreetingDisplay>

Look for the "ParseChildren" .NET attribute on your UserControl class. The
..NET documentation talks about this attribute and explains how you get
access to the embedded markup within the control tags.

If this doesn't help, please let me know :-)

--
venlig hilsen / with regards
anders borum
--
Nov 16 '05 #2
I already know how to exposing a public variable, but I was thinking doing
it all in the user control was better. However, I'm now thinking exposing
the public variable is the way to go. what do you think?

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

"Anders Borum" <an****@sphereworks.dk> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...
You could develop a UserControl that exposed a public property such as
GreetingText. When embedding the UserControl on the different physical
aspx
pages, you could simply set the getting text by assigning it to the
attribute of the server side control tag.

<CustomerName:GreetingDisplay id="ctrl" runat="server"
GreetingText="Here's
ny custom greeting text" />

This is the simple version. You could change the parsing of child controls
for the UserControl, allowing for more customization - e.g. by allowing
HTML
content within the opening and closing tags of the server side control
tag.

<CustomerName:GreetingDisplay id="ctrl" runat="server">
<div>
<b>Welcome!</b> <br />
<div>Some other text ..</div>
</div>
</CustomerName:GreetingDisplay>

Look for the "ParseChildren" .NET attribute on your UserControl class. The
.NET documentation talks about this attribute and explains how you get
access to the embedded markup within the control tags.

If this doesn't help, please let me know :-)

--
venlig hilsen / with regards
anders borum
--

Nov 16 '05 #3
Hello!

Well, you could keep the greeting text in an Xml file and associate the
different greeting elements with the name of the aspx files. Then, when the
UserControl loads, you simply load up the Xml file in an XmlDocument and
performs an XPath query against the XmlDocument.

If an XmlNode was found, you're off to setting the greeting text. Otherwise
just set the visibility of the UserControl to false or display a standard
greeting.

Don't forget to cache your XmlDocument in the ASP.NET Cache with a
dependency on your Xml file.

This approach is more flexible, as it allows for reuse of greetings across
many aspx pages.

Let me know what you think.

--
venlig hilsen / with regards
anders borum
--
Nov 16 '05 #4
What you did not like the declaring the public variable way? The Xml file
sounds cool, but I will never use the same greeting in two different .aspx
pages. Plus, my header user control contain more than just a greeting
(Header = all navigation links, log-in/log-out, etc) . what do you think now
or do you still believe the xml file way is the best way to go?

"Anders Borum" <an****@sphereworks.dk> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello!

Well, you could keep the greeting text in an Xml file and associate the
different greeting elements with the name of the aspx files. Then, when
the
UserControl loads, you simply load up the Xml file in an XmlDocument and
performs an XPath query against the XmlDocument.

If an XmlNode was found, you're off to setting the greeting text.
Otherwise
just set the visibility of the UserControl to false or display a standard
greeting.

Don't forget to cache your XmlDocument in the ASP.NET Cache with a
dependency on your Xml file.

This approach is more flexible, as it allows for reuse of greetings across
many aspx pages.

Let me know what you think.

--
venlig hilsen / with regards
anders borum
--

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: zdhiu | last post by:
Hi javascript gurus, I have a simple html file (simple.html) with javascript. In html page there is sentence from variable defined in .js file (myFirst.js). Once I reload another .js file...
11
by: The Bicycling Guitarist | last post by:
Oh lords and ladies of ciwah, I have already been told by one person that the <h1> on my home page doesn't look like proper semantic markup to them. That person suggested a <p> with style by CSS....
2
by: Mike | last post by:
Greeting to all, How i can in my web page ignore the page history? Thanks Mike
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
5
by: Greg Collins [MVP] | last post by:
I have an ASP.NET page that uses a tag: <asp:Xml id="foo" runat="server" DocumentSource="rss.xml" TransformSource="rss20.xsl" /> This creates a Web page from an XML file that was generated by...
0
by: All-Yours Greetings | last post by:
<HTML><HEAD><TITLE>all-yours.net</TITLE> <META NAME="a"> <METAA NAME="description" content="a"> <META http-equiv=Content-Type content="text/html; charset=windows-1252"> <META content="MSHTML...
3
by: tkaw220 | last post by:
Hi, I am looking to build an PHP application which will automatically send birthday greeting email to subscribers. The content of that email will change from time to time. Please help. Links to...
3
by: Pam1234 | last post by:
Hi everyone, This is a broad question but I'm hoping someone can steer me in the right direction. I can write valid xhtml strict in the dark with my eyes shut but I'm a trial-and-error person when...
1
by: ielamrani | last post by:
Hi All, First of all Happy Holidays. We usually do this piece manually. I want to find out if it's possible to send a Greeting card (Outlook card) to all our clients using their email address that...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.