Rev | Line | |
---|
[5186] | 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 {
|
---|
[6317] | 8 | public static class HtmlHelpers {
|
---|
[5186] | 9 |
|
---|
[6317] | 10 | public static string Truncate(this HtmlHelper helper, string input, int length) {
|
---|
| 11 | //takes a string and adds "..." if length > max length
|
---|
[5186] | 12 |
|
---|
[6317] | 13 | if (input == null)
|
---|
| 14 | return "";
|
---|
[5186] | 15 |
|
---|
[6317] | 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
|
---|
[5186] | 25 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.