Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 941
  • Last Modified:

Custom MembershipCreateStatus message

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
Starr Duskk
Asked:
Starr Duskk
  • 2
1 Solution
 
samtran0331Commented:
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
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
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
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
oh well. want to clear this out.
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now