ASP.NET
  Home arrow ASP.NET arrow Page 4 - Developing a Mini ASP.NET AJAX Server Cent...
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

Developing a Mini ASP.NET AJAX Server Centric Based Chat Application
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2008-12-09

    Table of Contents:
  • Developing a Mini ASP.NET AJAX Server Centric Based Chat Application
  • A Few Words About the Timer Control
  • The Login Module
  • HTML Code
  • Designing the Default.aspx Page

  • 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


    Developing a Mini ASP.NET AJAX Server Centric Based Chat Application - HTML Code


    (Page 4 of 5 )

    The following lists the key HTML markup code of the login.aspx page:

    <form id="form1" runat="server">

    <div style="text-align: center">

    <span style="font-size: 14pt; color: #3300ff"><strong>

    <br />

    FIRST LOGIN, THEN CHAT!<br />

    </strong></span>

    <br />

    <asp:ScriptManager ID="ScriptManager1" runat="server">

    </asp:ScriptManager>

    <br />

    <table width="400" cellpadding="0" cellspacing="2" align="center" border="0">

    <tbody>

    <tr>

    <td>

    &nbsp; &nbsp; &nbsp; &nbsp;User Name:</td>

    <td>

    <asp:TextBox runat="server" ID="txtUserName" /></td>

    </tr>

    <tr>

    <td>

    &nbsp; &nbsp; &nbsp; &nbsp;Password:</td>

    <td>

    <asp:TextBox runat="server" ID="txtPassword" TextMode="Password" />

    <br />

    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtPassword"

    ErrorMessage="The password cannot be empty" Display="Dynamic"></asp:RequiredFieldValidator></td>

    </tr>

    <tr>

    <td>

    &nbsp; &nbsp; Input your password again:</td>

    <td>

    <asp:TextBox runat="server" ID="txtRetypePwd" TextMode="Password" />

    <br />

    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtRetypePwd"

    ErrorMessage="The reentered password cannot be empty" Display="Dynamic"></asp:RequiredFieldValidator>

    <br />

    <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtPassword"

    ControlToValidate="txtRetypePwd" ErrorMessage="The two passwords must be the same" Display="Dynamic"></asp:CompareValidator></td>

    </tr>

    </tbody>

    </table>

    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">

    <ProgressTemplate>

    <div class="loading">

    Verifying the logging in info......</div>

    </ProgressTemplate>

    </asp:UpdateProgress>

    <br />

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">

    <ContentTemplate>

    <asp:Label runat="server" ID="lblMessage" />

    <br />

    <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" />

    </ContentTemplate>

    </asp:UpdatePanel>

    &nbsp;&nbsp;

    <ul>

    <li style="text-align: center">If it's the first time that you log in , then you can enter any temporary password to enter the chat lobby.</li><li style="text-align: center">

    If you've logged into the system and not been overdue, just enter your temporary password to

    reenter.</li></ul>

    </div>

    </form>

    As is shown above, when the "login" button is clicked, its related click event handler is triggered to perform the register and logging in operations. This is implemented in the following code:

    protected void btnLogin_Click(object sender, EventArgs e)

    {

    System.Threading.Thread.Sleep(3000);

    string userName = this.txtUserName.Text.Trim();//username

    string password = this.txtPassword.Text.Trim();//password

    string retypePwd = this.txtRetypePwd.Text.Trim();//reentered password

    //The user are in the chatting room, but the password just entered is incorrect

    if (Room.Instance.UserIsChatting(userName)&&Room.Instance.GetUser(userName).Password != password)

    {

    this.lblMessage.Text = "Please enter the right password";

    }

    else//login successfully

    {

    if (!Room.Instance.UserIsChatting(userName))//The entered username is not chatting

    {

    Room.Instance.AddUser(userName, password);//add the user

    //send out a system message

    Room.Instance.SendMessage(String.Format("{0} Enters the chatting room", userName));

    }

    Room.Instance.GetUser(userName).Update();

    FormsAuthentication.RedirectFromLoginPage(userName, false);

    }

    }

    First, check the chat room to see whether the user exists or not. If so, then continue to verify the password. Moreover, if the password is valid, logging in is successful; otherwise, the user is required to re-enter his password. If the current user does not reside in the chat room, then he is joined to the system, and after that, he is allowed to enter the chat room.

    Note that to gain a clear impression of the prompt effect when the system is loading, we purposely let the system sleep three seconds.

    Next, let us take a look at the main chat Default.aspx page information.

    More ASP.NET Articles
    More By Xianzhong Zhu


       · bisedochat
     

    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 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek