ASP.NET PasswordRecovery Control with Localized content
-
03-07-2019 - |
Question
I am working on a simple portal application using the ASP.NET membership and login controls. I would like to use the PasswordRecovery control to send emails containing forgotten passwords, however my portal requires localization. I have an existing Content Management System that I am pulling the localized strings out of and I would like to link the PasswordRecovery control to that system.
But, it appears that the PasswordRecovery control will ONLY accept a .txt file for the email body...the property is PasswordRecovery1.MailDefinition.BodyFileName
I do not want to use a file on disk, I would like to use the localized content in my CMS.
Is there any way to do this? It occurred to me that I might be able to use the SendingMail event to send my OWN email through the normal System.Net namespace, but that seems sorta cludgy...
Any thoughts?
Thanks, Max
Solution
Try handling the SendingMail event of the PasswordRecovery control. In that event, set the e.Message.Body and e.Message.Subject properties to your localized text.
OTHER TIPS
Found this by googling "BodyFileName localization":
http://forums.asp.net/t/1118242.aspx:
Just bind the property to a key in your page's localresource file. The page's local resource file is the file located in a subdirectory called app_localresources in your page's directory. Just use visual studio's "tools -> create local resource" option in design view for it be created for you.
In that file, create a string key/value pair with something like
Name: myBodyFileName
Value: myDefaultBodyFile.txt
Then bind this to the BodyFileName property of the login control with something like
'>
Then just create the sattelite local resource files for other cultures and map that key/value pair in those resources to other body text files.
By the way, if you used visual studio to create the resource file for you, then the binding may have been done for you automatticaly. Just search for a "MyChangePasswordControlResource1.BodyFileName" key in the resource file or something similar.
Regards, Jorge