The problem seems to be how the string is been presented in the HTML truncate.
var text = node.Value<string>("pageContent");
var content = node.Value<string>("content");
var rText = Html.StripHtml(text, null);
var rContent = Html.StripHtml(content, null);
string rrText = rText.ToHtmlString();
Using this when the page loads I get an error.
@Html.TruncateByWords(rrText, 10)
However if I replace the rrText with a text statement it works.
@Html.TruncateByWords("An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.", 10)
Truncating words
Hello,
I am trying to create my own version of a Search on my website
https://test.teespen.org.uk/search-results-2?query=form
I am trying to give a brief description from the page but I cannot get it to truncate.
This is the code so far:
Everytime I use different truncate styles, it keeps coming back saying the value
@Html.TruncateByWords(rrText, 10)
I cannot figure it out any ideas please help.
You could try the Umbraco Helper: @Umbraco.Truncate(rText, 10)
Also in your example you have a rrText in the truncate statement and rText in the main code block, possible its just a typo?
Hi,
No rrText was not a typo, in another version I tried to convert rText to String which set to var rrText.
I will try this method.
Thanks
no that didn't work
Ok I have moved forward slightly.
The problem seems to be how the string is been presented in the HTML truncate.
Using this when the page loads I get an error.
However if I replace the rrText with a text statement it works.
GOT IT
Looked into @Html.Truncate and added all of the operators it required and it's now working.
Thanks everyone
is working on a reply...