Reputation: 1775
My Scenario: I'm using the RadEditor control as an editor on a form that the user fills out to submit an Email. The RadEditor is where the user types the body of the email. We have some Email templates stored as HTML in our database that the user can select via a dropdown on the form. The templates are full HTML having their own head tags and style tags with their own styles.
My Question:
Can I set the RadEditor content to the full HTML of my templates? I would like to be able to set the content of the editor to the full HTML and be able to get the full HTML out of the RadEditor on the server code-behind. I am currently trying to do this but when I use the .Content property of the editor, I'm only getting what is inside of the <body>
tags, not the full HTML. This is problematic when I need to save the editor content back to the database after the user has entered content, because I need to the full HTML to be saved to the database.
Is my approach incorrect and instead should I be only trying to save and retrieve the body of the Editor's html, not the full html? In that case, how would I deal with different styles that need to be applied for each my Email templates?
Please note that I've been using the ContentAreaMode="Iframe"
setting of the editor.
Thank you!!!
Upvotes: 0
Views: 3716
Reputation: 15797
I think your approach is correct. How to complete it:
Instead of saving the "full html" to the database, save the RadEditor.Content
HTML and (in another column) the ID of the HTML template they chose. This will be nice if they ever want to change the template.
Your HTML templates can have some type of "placeholder" to let you know where to "insert" the HTML from the RadEditor. Let's say your HTML template has in it the text %%BODY%%
.
When you are ready to send the email, get the template, the RadEditor.Content
(either from the postback or from querying the database), and combine them. Something like
string htmlTemplate = //your HTML template from your database
string body = htmlTemplate.Replace("%%BODY%%", RadEditor.Content); //the string 'body' is what will be sent as your email body.
Upvotes: 3