---
title: "remove exceed string using JavaScript in MVC 4"  
description: "remove exceed string using JavaScript in MVC 4"  
author: "Anonymous User"  
published: 2013-02-14  
updated: 2013-02-16  
canonical: https://www.mindstick.com/forum/604/remove-exceed-string-using-javascript-in-mvc-4  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 1 minute  

---

# remove exceed string using JavaScript in MVC 4

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances)!

I'm working on [MVC project](https://www.mindstick.com/forum/158706/how-do-you-establish-a-database-connection-in-an-asp-dot-net-mvc-project). I have bind [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) into MVC [control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control) through property. I want to display exceed string as below

"[Model](https://yourviews.mindstick.com/view/81334/america-is-reopening-after-corona-lockdown-but-on-swedish-model) [View](https://yourviews.mindstick.com/view/84701/layoffs-in-google-india-2023-view) Control Demo..."

My [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) as below

@Html.DisplayFor(modelItem => item.Description)

Please reply ASAP!

Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by AVADHESH PATEL

Hi Jeet!

Create helper method for remove exceede string from fixed lenght

```
@helper Truncate(string input, int length)        {            if (input.Length <= length)            {        @input            }            else            {        @input.Substring(0, length)<text>...</text>            }    }
```

Use this method in place of your [MVC](https://www.mindstick.com/forum/155803/define-cache-profile-in-mvc) control

@Truncate(item.Description, 30)


---

Original Source: https://www.mindstick.com/forum/604/remove-exceed-string-using-javascript-in-mvc-4

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
