Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Custom MembershipCreateStatus message

Posted on 2007-11-15
3
Medium Priority
?
935 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
[X]
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
  • 2
3 Comments
 
LVL 37

Accepted Solution

by:
samtran0331 earned 2000 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

A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

715 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