Solved

Custom MembershipCreateStatus message

Posted on 2007-11-15
3
923 Views
Last Modified: 2013-11-07
I have created a custom MembershipProvider class.

In it, I am checking:

        ' check if application requires a unique email and if the email already exists...
        If RequiresUniqueEmail AndAlso GetUserNameByEmail(email) <> "" Then
            status = MembershipCreateStatus.DuplicateEmail
            Return Nothing
        End If

Instead of having it print to the screen the default message that the email already exists, I want to send my own custom message instead. How do I override the message for the MembershipCreateStatus.DuplicateEmail?

thanks.
0
Comment
Question by:BobCSD
  • 2
3 Comments
 
LVL 37

Accepted Solution

by:
samtran0331 earned 500 total points
ID: 20292034
Bob,
Didn't we go over that here?
http://www.experts-exchange.com/Microsoft/Development/.NET/.NET_Framework_2.0/Q_22950749.html

With the relevant example from MSDN here:
http://msdn2.microsoft.com/en-us/library/system.web.security.membershipcreatestatus.aspx

I don't know what your full function is (is it returning a string?), but within what you posted:
If RequiresUniqueEmail AndAlso GetUserNameByEmail(email) <> "" Then
            status = MembershipCreateStatus.DuplicateEmail
            Return Nothing
End If

since you have the status, you can use the MSDN "GetErrorMessage" function almost the way it is on MSDN...just change the string text in fn.

even if your full function isn't returning a string, you can pass in a string variable by ref and use the GetErrorMessage function to set the string variable...
0
 
LVL 1

Author Comment

by:BobCSD
ID: 20316428
The previous example was in a click event in the codebehind of a log in page. and the Msg.Text is being set to the return value from a function which is also in the log in page:

Msg.Text = GetErrorMessage(status)

I am not using a log in page click event. If I wanted to, that would certainly likely do it.

My question is in regard to setting the returned message from within the custom membership provider, not having to setup an error handling routine on every page that uses the membership provider. I would have to setup a click event and an errorhandling routine for login, change password, register, forgot password, all that good stuff. And I know when I hit the membership provider functions what my error message should be, so I want to set it in there and have it return it to the red error message.

I mean, microsoft is getting these messages from somewhere... so I should be able to override the value returned within my custom membership provider... one would think.... without having to write a detailed click event and error handler.




0
 
LVL 1

Author Comment

by:BobCSD
ID: 20377372
oh well. want to clear this out.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

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

23 Experts available now in Live!

Get 1:1 Help Now