ASP.NET
  Home arrow ASP.NET arrow Page 6 - User and Role Management for an ASP.NET AJ...
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

User and Role Management for an ASP.NET AJAX Server-Centric Based Online Shopping Website
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 7
    2007-12-19

    Table of Contents:
  • User and Role Management for an ASP.NET AJAX Server-Centric Based Online Shopping Website
  • Role Management
  • New Role
  • User Management
  • Deleting the Selected User
  • Adding Background Users

  • 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


    User and Role Management for an ASP.NET AJAX Server-Centric Based Online Shopping Website - Adding Background Users


    (Page 6 of 6 )


    Adding Background Users

    Clicking the "Add new user" button within the GridView control will redirect the user to another important page, "AddAdminUser.aspx." On the face of it, this part is pretty similar to the user registration discussed before, but here we can assign special kinds of roles to the newly-added user whereas the foreground user registration can not.

    Interface Design

    When designing this page, we’ve also introduced three ASP.NET AJAX Extender controls: TextBoxWatermarkExtenderto render the watermark effect to the "UserName" TextBox, PasswordStrengthto test the strength of the password the user enters, and ValidatorCalloutExtenderto give a friendlier hint message when the user enters an invalid email address. The following figure 14 gives the corresponding design-time snapshot.


    Figure 14—the design-time snapshot for registering background users

    There’s nearly nothing peculiar here but a DropDownList control named "RoleList" for the manager to select the role!

    Page Initialization

    There’s only one task to perform in initializing the page: binding data to the "RoleList" DropDownList control.

    protected void Page_Load(object sender,EventArgs e) {

    ///bind data to the control

    if(!Page.IsPostBack) {

    BindRoleData();

    }

    }

    private void BindRoleData(){

    ///define the class that gets the data

    Role role = new Role();

    SqlDataReader recr = role.GetRoles();

    ///Set the control's data source

    RoleList.DataSource = recr;

    RoleList.DataTextField = "RoleName";

    RoleList.DataValueField = "RoleID";

    ///bind data to the control

    RoleList.DataBind();

    ///Close the database connection

    recr.Close();

    }

    Here we’ve also appended sufficient comments for readers to refer to. So, let's continue to see the adding operation.

    Adding a Background User


    The adding function here is also simple.

    protected void SureBtn_Click(object sender,EventArgs e){

    User user = new User();

    int nUserID = user.AddUser(UserName.Text,RealName.Text,Password.Text,

    Address.Text,Phone.Text,Mobile.Text,Email.Text,

    Int32.Parse(RoleList.SelectedValue),Remark.Text);

    Response.Write("<script>alert('" + "Adding operation is successful. Please safekeep your data!" + "');</script>");

    }

    As you’ve seen, after adding the new user data into the back end database we only need to show the manager a friendly hint message.

    Last but not least, when you test this page you should remember the phone and mobile numbers format or modify them according to you own needs.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    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