Solved

CreateUserWizardControl - how to exit and display error

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 - SQL Timeout 9 34
"Emulate" TAB key when press Enter Key 3 49
edit .asp files 5 31
how to remove duplicate code from my project 5 37
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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 video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

830 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