Solved

CreateUserWizardControl - how to exit and display error

Posted on 2014-02-11
1
235 Views
Last Modified: 2014-02-24
Hi

I have a CreateUserWizard control which is highly customised

On this void:
 protected void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e)
    {

Open in new window


I want to call another void called checkAuthorisedEmployeeNumber

    void checkAuthorisedEmployeeNumber(string EmpNo) { 
    
        if (EmpNo == "123456"){
            //user not allowed to register
            //exit the create user wizard and show error message
            
        }

    }

Open in new window


This is working, but i want to cancel the createUser process and show an error message saying that the user isn't in the authorised list, and cannot register

Can someone help with this code please
0
Comment
Question by:websss
1 Comment
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 39854588
1: Make your checkAuthorisedEmployeeNumber return bool: true or false
2: Set e.Cancel accordingly
3: Set the errorMessage

bool checkAuthorisedEmployeeNumber(string EmpNo) { 
    
        if (EmpNo == "123456"){
            return false; //employee not allowed to create account
         }
         return true; // by default allow to create the account
    }

protected void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e)
{
     if(checkAuthorisedEmployeeNumber(EmpNo) ==false)
     {
             SomeErrorLabel.Text = "You are not allowed to create an account"
             e.Cancel = true;
     }
}

Open in new window

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now