Rev | Line | |
---|
[5756] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Web;
|
---|
| 5 | using System.Web.Mvc;
|
---|
| 6 |
|
---|
| 7 | namespace HLWebOKBAdminPlugin.Helpers {
|
---|
| 8 | public static class HtmlHelpers {
|
---|
| 9 |
|
---|
| 10 | public static string Truncate(this HtmlHelper helper, string input, int length) {
|
---|
| 11 | //takes a string and adds "..." if length > max length
|
---|
| 12 |
|
---|
| 13 | if (input == null)
|
---|
| 14 | return "";
|
---|
| 15 |
|
---|
| 16 | if (input.Length <= length) {
|
---|
| 17 | return input;
|
---|
| 18 | }//if
|
---|
| 19 | else {
|
---|
| 20 | return input.Substring(0, length) + "...";
|
---|
| 21 | }//else
|
---|
| 22 | }//Truncate
|
---|
| 23 |
|
---|
| 24 | }//HtmlHelpers
|
---|
| 25 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.