Explanation: Model.BodyText.ToString() gives you the raw HTML and then from there you can use any standard String method, such as Substring(). The Html.Raw razor helper method is used to tell Razor NOT to HTML Encode the output.
Just note you always risk splitting in the middle of an HTML tag using this method. A better way is to strip out HTML first and then perform a substring. There are umbraco.library helpers to do this.
Substring
Seems like this should be easy - how do I get a substring of say @item.BodyText in a template file?
Just want to display a snippet..
thanks
If, say, you wanted just the first 150 characters you would do:
Explanation: Model.BodyText.ToString() gives you the raw HTML and then from there you can use any standard String method, such as Substring(). The Html.Raw razor helper method is used to tell Razor NOT to HTML Encode the output.
Just note you always risk splitting in the middle of an HTML tag using this method. A better way is to strip out HTML first and then perform a substring. There are umbraco.library helpers to do this.
thank you
is working on a reply...