Wiley 978-0-471-74951-6 Datasheet

Browse online or download Datasheet for Software manuals Wiley 978-0-471-74951-6. Wiley ASP.NET 2.0 Instant Results User Manual

  • Download
  • Add to my manuals
  • Print
  • Page
    / 36
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 0
1
The Online Diary
and Organizer
By the end of this chapter you’ll have created an online diary, organizer, and contacts manager. So
what exactly does the online diary and organizer do? Using a calendar-based interface it allows
you to add, delete, and edit a diary entry for any day. It also allows you to create events: for exam-
ple, to keep a note of your rich Uncle Bob’s birthday wouldn’t want to forget that, would you?
It’s not just limited to birthdays, but any event: meetings, appointments, and so on.
The system has a basic username and password logon system, so that only you and no one else
can view your own diary. This is what differentiates it from a blog. This system is a private diary
and contacts manager a place to put all those thoughts and comments you’d rather not have the
world see. Unlike a blog, where you want the world to see it!
This whole project demonstrates the power of ASP.NET 2.0 and how easy it makes creating pro-
jects like this. Gone are the days of hundreds of lines of code to do security logons, create new
users, and so on. This chapter employs the new security components of ASP.NET 2.0 to show just
how easy it is to create fun, exciting, and useful projects.
The first section takes you through using the diary and its main screens. Then, the “Design of the
Online Diary” section walks you through an overview of the system’s design. After that you get
into the nuts and bolts of the system and how it all hangs together. In the final section, you set up
the diary.
Using the Online Diary
Each user has his or her own online diary; to access it requires logging on. Enter username user5
with the password 123!abc to log in as a test user. The log on screen is shown in Figure 1-1.
Although the screenshot may suggest lots of controls and lots of code to make the security func-
tion, in fact with the new security controls in ASP.NET 2.0 it’s very easy and not much work at all.
If you have not registered, a link will take you to the Sign Up page, depicted in Figure 1-2.
04_749516 ch01.qxp 2/10/06 9:11 PM Page 1
COPYRIGHTED MATERIAL
Page view 0
1 2 3 4 5 6 ... 35 36

Summary of Contents

Page 1 - COPYRIGHTED MATERIAL

1The Online Diaryand OrganizerBy the end of this chapter you’ll have created an online diary, organizer, and contacts manager. Sowhat exactly does the

Page 2

Method Return Type DescriptionGetContactsByFirstLetterAsCollection(ByVal SqlDataReader Shared method DiaryId As Integer, Optional ByVal that returns

Page 3

The ContactCollection class has only one property:Property Type DescriptionItem(ByVal Index As Integer) Integer Returns the Contact object stored at t

Page 4

Having created a DiaryEntry object, saving it involves simply calling the Save() method. As with theSave() method of the Contacts class, the DiaryEntr

Page 5

Method Return Type DescriptionGetDiaryEntriesByDateAsCollection(ByVal DiaryEntryCollection Creates a new DiaryId As Integer, ByVal FromDate DiaryEntr

Page 6 - Design of the Online Diary

Along with the Item() property, the DiaryEntryCollection class has three public methods:Method Return Type DescriptionAdd(ByVal New DiaryEntry None

Page 7

The following table explains these methods in detail:Method Return Type DescriptionSave() None Saves a fully populatedDiaryEvent object. If it’sa new

Page 8 - The Business Layer

Method Return Type DescriptionDeleteEvent() None Deletes from the database theevent with EventId equal tomEventId of the object. TheDiaryEvent object’

Page 9

This class contains only one property:Property Type DescriptionItem(ByVal Index As Integer) Integer Returns the DiaryEvent object stored atthe positio

Page 10 - Chapter 1

Each of the seven class files is stored in the App_Code directory (at the top of the figure). The App_Datadirectory contains the two databases: the lo

Page 11 - The DiaryEntry Class

Font-Names=”Verdana” Font-Size=”0.8em”ForeColor=”#284775” /><TextBoxStyle Font-Size=”0.8em” /><TitleTextStyle BackColor=”#5D7B9D” Font-Bol

Page 12

Figure 1-1Figure 1-2This shows another of the new security controls in ASP.NET 2.0; creating a registration process is nowjust a matter of adding a co

Page 13

<NavigationButtonStyle BackColor=”#FFFBFF” BorderColor=”#CCCCCC”BorderStyle=”Solid”BorderWidth=”1px” Font-Names=”Verdana” ForeColor=”#284775” />

Page 14

</table></asp:WizardStep><asp:CompleteWizardStep runat=”server”><ContentTemplate><table border=”0” style=”font-size: 100%;

Page 15

Figure 1-13Figure 1-14This screen asks users for their first name and last name. This time it’s up to you to store the data some-where, and you do tha

Page 16

This step creates a new diary for users and stores their first and last names. The UserName comes fromthe CreateUserWizard control’s UserName property

Page 17 - Code and Code Explanation

Viewing the Online CalendarThe DiaryMain.aspx page is the central hub of the application. It displays a calendar of the currentmonth, showing which da

Page 18

However, the new ObjectDataSource lets you have the best of both: easy-to-use data controls and use ofclasses to separate business, data, and presenta

Page 19 - New User Registration

<asp:BoundField DataField=”EntryText” /></Columns><PagerStyle BackColor=”#284775” ForeColor=”White”HorizontalAlign=”Center” /><Se

Page 20

mDiaryEntry is a global variable used to hold the DiaryEntry object relating to the day being edited.The constructor, shown in the following code, doe

Page 21

When the diary title or entry boxes are changed, mDiaryEntry is updated:Protected Sub entryTitleTextBox_TextChanged(ByVal sender As Object, ByVal e As

Page 22

diaryDBConn = NothingEnd IfEnd SubThe private method UpdateDiaryEntry() updates it:Private Sub UpdateDiaryEntry()If mDiaryEntryId <> -1 ThenDim

Page 23 - Password Reminder

Figure 1-4On this page you see a monthly calendar. Days with diary entries are marked with a blue background.Days with events are marked in red text.

Page 24 - Viewing the Online Calendar

Type=”DateTime” /><asp:Parameter DefaultValue=”0” Name=”MaxRows” Type=”Int32” /></SelectParameters><DeleteParameters><asp:Para

Page 25

In addition, the code specifies a Delete button on each row in the grid:<asp:CommandField ShowDeleteButton=”True” />When you click the Delete bu

Page 26

itemToSelect =eventDurationDropDownList.Items.FindByValue(EventBeingEdited.EventDuration.ToString())itemToSelect.Selected = TrueEventBeingEdited = Not

Page 27

It gets its data from the ObjectDataSource control ObjectDataSource1, which in turn connects to theContact class’s GetContactByFirstLetter() shared me

Page 28

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)Handles Me.LoadIf IsPostBack ThenDim currentContact As NewContact(CLng(Req

Page 29

Alternatively, if you have IIS installed make the OnlineDiary directory you copied over a virtual direc-tory and then simply browse to SignOn.aspx.To

Page 30

04_749516 ch01.qxp 2/10/06 9:11 PM Page 36

Page 31

You can also navigate your diary from here via the small calendar to the right.Adding a diary entry simply involves typing in the Entry Title and Diar

Page 32 - Managing Contacts

Figure 1-8Here you see a list of your contacts, which you can edit and delete by clicking the appropriate link in theContacts table. You can also add

Page 33

So you’ve seen what the Online Diary does, now you can look at how it does it! The next sectiondescribes the overall design and how the system hangs t

Page 34 - Setting up the Online Diary

The default database created using the new membership features of ASP.NET 2.0 is also used. Thedatabase is a SQL Server Express database and not modif

Page 35 - ObjectDataSource

Consider this very simple stored procedure:DeleteContactRather unsurprisingly, DeleteContact deletes a contact from the database. The naming conventio

Page 36

It has two constructors, outlined in the following table: Constructor DescriptionNew(ByVal Diaryid as Integer) Creates a new Contact object with all p

Comments to this Manuals

No comments