I'm currently using EpiServer 7.5 with ASP.Net MVC.
Basically, I'm defining a property inside a model which needs to be of type XHtmlString. What I wish to do inside the model is set a default value for the XHtmlString, but since this is represented by a string, how can I do this?
Here's an example in code - this is my model:
[Required]
[Display(
Name = "Thank you message",
Order = 1)]
public virtual XhtmlString ThankYouMessage{ get; set; }
Now, later on the code, I simply want to set the default value of this ThankYouMessage type to a string.
ThankYouMessage = "Default thank you message";
This won't work because ThankYouMessage is an object type of XHtmlString and I obviously can't set this to a type of string.
I think it has something to do with the XHtmlStringConverter but I can't figure this out - any help would be appreciated.
Cheers!
You'll need to convert the string into an XhtmlString as that is the property type. This is simply done by creating a new XhtmlString object.
ThankYouMessage = new XhtmlString("Default thank you message")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With