+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / How to trim the text length from the description field if we have the image in the description?

How to trim the text length from the description field if we have the image in the description?

2 posts, 0 answered
  1. Venkata
    Venkata avatar
    1 posts
    Registered:
    15 Sep 2014
    15 Sep 2014
    Link to this post

    Hello there

     I want to trim the text length to 100 characters for the description I have used the code like 

    <%# Eval("Content").ToString().Substring(0, 100)%> it is working fine and I am getting the result.

    The problem is if we have the image and then content in the description field it is not showing any results, it is giving empty result.

    How can i violate the image in the description and display only 100 characters of the text.

    Thanks in advance.

  2. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    07 Dec 2016
    18 Sep 2014
    Link to this post
    Hi Venkata,

    Actually this option will render the html but it is cut on character 100. So in case of any html tags in the content that is not closed - this will brake the html at all (for example: " some text <img src='/images/img1.j' ".

    So I would recommend you to use a Summary field or create a custom filed of type Textbox where to place the summary as plain text and cut it at any character you need (as in your code).

    Regards,
    Svetoslav Manchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
2 posts, 0 answered