Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Custom MembershipCreateStatus message

Posted on 2007-11-15
3
926 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:Starr Duskk
  • 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 2

Author Comment

by:Starr Duskk
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 2

Author Comment

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

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

861 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