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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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 / 5
    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

    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ
    - Developing a Dice Game Using ASP.NET Futures...
    - Completing an ASP.NET AJAX Server-Centric Ba...
    - Information Management for an ASP.NET AJAX S...
    - Comment and Order Management for an ASP.NET ...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT