ASP.NET
  Home arrow ASP.NET arrow Finishing an Online E-Mail System in ASP.N...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Finishing an Online E-Mail System in ASP.NET 2.0
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2007-06-13

    Table of Contents:
  • Finishing an Online E-Mail System in ASP.NET 2.0
  • Deleting Folders
  • Reading Your Email
  • Deleting Your Email
  • Moving Your Email

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Finishing an Online E-Mail System in ASP.NET 2.0


    (Page 1 of 5 )

    Yesterday we began designing the interface for an online e-mail system in ASP.NET 2.0. Today, in the conclusion to this four-part series, we pick up where we left off. As you'll recall, the last thing we did was learn how to create folders; in this article, we'll learn how to rename and delete folders, and read and move e-mail.
    A downloadable .rar file is available for this article.

    Renaming Folders

    In this sample, renaming the folder is achieved through the RenameFolder.aspx, page. Figure 10 shows the relevant design-time snapshot.

    Figure 10-the design-time view of the RenameFolder.aspx page

    Since there are few controls on the page and their functions can be easily doped out, we choose not to waste time on the controls but to dive right into the associated code.

     

    int nFolderID = -1;

    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)

      { ///show name of the folder

        if(nFolderID > -1) { BindFolderData(nFolderID); }

      }

    }

    private void BindFolderData(int nFolderID)

    {

      IFolder folder = new Folder();

      SqlDataReader dr = folder.GetSingleFolder(nFolderID);

      if(dr.Read())

      {

        Name.Text = dr["Name"].ToString();

      }

      dr.Close();

    }

     

    Here, when the RenameFolder.aspx page is initialized, we first obtain the value of the nFolderID parameter out of the address bar (of the browser), then call a helper function named BindFolderData which bears the responsibility of grabbing the information of the folder out of the database using the nFolderID parameter, and then displays the folder name in the text box called Name. Next, when you click the OK button (with the id of RenameBtn), renaming is started:

     

    protected void NewBtn_Click(object sender,EventArgs e)

    {

      try

      { ///define the object

        IFolder folder = new Folder();

        ///execute

        folder.RenameFolder(nFolderID,Name.Text.Trim());

        Response.Write("<script>alert('" + "Renaming succeeded, safekeep you data!" + "');</script>");

      }

      catch(Exception ex)

      { ///jump to the page dealing with exception handling

        Response.Redirect("ErrorPage.aspx?ErrorMsg=" + ex.Message.Replace("<br>","").Replace("n","")

          + "&ErrorUrl=" + Request.Url.ToString().Replace("<br>","").Replace("n",""));

      }

    }

     

    Here, when you click the OK button, the NewBtn_Click event is triggered to call the helper function named RenameFolder to rename the folder and persist the new name into the database. Finally, clicking the Return button will navigate you back to the MailDesktop.aspx page.

    More ASP.NET Articles
    More By Xianzhong Zhu


     

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek