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 ...
Get Beginning ASP.NET 3.5: In C# and VB now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.