Skip to Content
Beginning ASP.NET 3.5: In C# and VB
book

Beginning ASP.NET 3.5: In C# and VB

by Imar Spaanjaars
March 2008
Intermediate to advanced content levelIntermediate to advanced
766 pages
21h 15m
English
Wrox
Content preview from Beginning ASP.NET 3.5: In C# and VB

A.9. Chapter 9

A.9.1.

A.9.1.1.
A.9.1.1.1. Exercise 1 solution

First, you need to write a property in the Code Behind of the user control, similar to the DisplayDirection property you created in the previous chapter for the Banner control. This property could look like this:

VB.NET

Private _pageDescription As String
Public Property PageDescription() As String
  Get
    Return _pageDescription
  End Get
  Set(ByVal Value As String)
    _pageDescription = Value
  End Set
End Property

C#

public string PageDescription { get; set; }

You then need to modify the control declaration. For example, in Contact.aspx, you can modify the control like this:

<uc1:ContactForm ID="ContactForm1" runat="server" PageDescription="Contact Page" />

Note that the PageDescription property contains a short description of the containing page. Obviously, you can put whatever text you see fit to describe the page in the property.

Finally, you need to add the PageDescription to the subject or body of the e-mail message. The following code snippet shows you how to extend the subject with the value of this new property:

VB.NET

myMessage.Subject = "Response from web site. Page " & PageDescription
myMessage.From = New MailAddress("you@yourprovider.com", "Sender Name Here")

C#

myMessage.Subject = "Response from web site. Page " + PageDescription;
myMessage.From = new MailAddress("you@yourprovider.com", "Sender Name Here");

From now on, this custom page description is added to the subject of the mail message.

A.9.1.1.2. Exercise ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning ASP.NET 4: in C# and VB

Beginning ASP.NET 4: in C# and VB

Imar Spaanjaars
Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Bill Evjen, Scott Hanselman, Devin Rader

Publisher Resources

ISBN: 9780470187593Purchase book