c# - umbraco string trim using razor view -


i have umbraco script im using on site, inside there razor script below:

<p>@page.getproperty("maincontent")</p> 

the above in loop, , shows content each post (its being used on landing page blog functionality)

i want trim content outputed getpropery() method 300 charectors.

anyone have ideas?

also, word opposite of concatenate?

you write custom helper:

public static class htmlextensions {     public static string truncate(this htmlhelper html, string value, int count)     {         if (string.isnullorempty(value))         {             return string.empty;         }          if (value.length > count)         {             value = value.substring(0, count - 1) + "...";         }          return value;     } } 

which used this:

<p>@html.truncate(page.getproperty("maincontent"), 300)</p> 

also, word opposite of concatenate?

split


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -