trim news title characters length to 20 in latest news webpart

mmm mmmm asked on May 7, 2014 14:07

how can i trim news title characters length to 20 in latest news webpart(not in database attribute)

Correct Answer

Brenden Kehren answered on May 8, 2014 06:55

The below will get you a shortened version of the news summary data. Keep in mind the pad string ("...") counts towards the length (100 in this case).

<%# LimitLength(Eval("NewsSummary"), 100, "...", true) %>
1 votesVote for this answer Unmark Correct answer

Recent Answers


Yehuda Lando answered on May 7, 2014 16:10 (last edited on May 7, 2014 16:10)

You can use the macro method LimitLength(string text, int length, string padString, bool wholeWords) in your transformation. The last two parameters are optional.

1 votesVote for this answer Mark as a Correct answer

mmm mmmm answered on May 8, 2014 06:39

first thank you for your speed respons, but can you help me more how to add the macro in this news transformation :

<%# GetDateTime("NewsReleaseDate", "d") %>
<%# Eval("NewsSummary") %>

and thank you again

0 votesVote for this answer Mark as a Correct answer

mmm mmmm answered on May 8, 2014 07:16

thank you very much it is worked very well and thank you again

0 votesVote for this answer Mark as a Correct answer

Rananjay Singh answered on June 15, 2015 11:22

You can use this

<%# LimitLength(Eval("NewsSummary"), 100, "...", true) %>

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.