Designing the Interface and More for an Online E-Mail System in ASP.NET 2.0 - Check the E-mails in Your Mailbox
(Page 4 of 5 )
Now, let's turn our attention to how to view the e-mails in the selected mailbox, which is done on the ViewMail.aspx page (figure 8 shows the design-time interface).
Figure 8-the design-time snapshot of the ViewMail.aspx page

Here, we enumerate the functions of the controls on this page as follows:
GridView MailView -- to show the e-mails in the selected mailbox;
DropDownList FolderList -- to show the mailboxes/folders to which the selected e-mails are moved;
Button DeleteBtn -- to delete the mails checked out (i.e. selected);
Button MoveBtn - -to move the selected e-mails to the mailbox currently selected in control DropDownList.
As discussed in the MailDesktop.aspx page, the main task is finished when the page is loaded. When the ViewMail.aspx page is initialized, we need to perform the following functions:
1. Obtain the value of the nFolderID parameter;
2. Display the e-mails within the current mailbox or folder in the MailView control, which is accomplished by calling the helper function BindMailData which in turn invokes the GetMailsByFloder method of the Mail class to get the details (such as mail topic, sending time, sender, and so forth) of all the e-mails in the current mailbox/folder using the nFolderID parameter;
3. Exhibit the information about the mailbox/folder in the FolderList control, which is done with the helper function BindFolderData.
int nFolderID = -1;
protected string AliasName = "AliasName";
protected string Email = "Email";
protected void Page_Load(object sender,EventArgs e)
{
///get the value of parameter nFolderID
if(Request.Params["FolderID"] != null)
{
if(Int32.TryParse(Request.Params["FolderID"].ToString(),out nFolderID) == false)
{ return;}
}
if(!Page.IsPostBack){
if(nFolderID > -1)
{
BindMailData(nFolderID);
BindFolderData();
}
}
DeleteBtn.Attributes.Add("onclick","return confirm('Are you sure to delete the selected files?');");
}
private void BindFolderData()
{ ///get data
IFolder folder = new Folder();
SqlDataReader dr = folder.GetFolders();
///bind data
FolderList.DataSource = dr;
FolderList.DataTextField = "Name";
FolderList.DataValueField = "FolderID";
FolderList.DataBind();
dr.Close();
MoveBtn.Enabled = FolderList.Items.Count > 0 ? true : false;
}
private void BindMailData(int nFolderID)
{ ///get data
IMail mail = new Mail();
SqlDataReader dr = mail.GetMailsByFloder(nFolderID);
///bind data
MailView.DataSource = dr;
MailView.DataBind();
dr.Close();
DeleteBtn.Enabled = MailView.Rows.Count > 0 ? true : false;
}
Indeed, there is nothing more to be interpreted in the above code, so let's continue the long journey.
Next: Creating Folders >>
More ASP.NET Articles
More By Xianzhong Zhu