Solved

CreateUserWizardControl - how to exit and display error

Posted on 2014-02-11
1
240 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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