---
title: "How to remove extra blank space(after/before) from content into the \"Summernote Editor\" ?"  
description: "How to remove extra blank space(after/before) from content into the \"Summernote Editor\" ?"  
author: "Anonymous User"  
published: 2019-07-04  
updated: 2023-06-18  
canonical: https://www.mindstick.com/forum/55138/how-to-remove-extra-blank-space-after-before-from-content-into-the-summernote-editor  
category: "asp.net mvc"  
tags: ["asp.net mvc", "mvc"]  
reading_time: 2 minutes  

---

# How to remove extra blank space(after/before) from content into the "Summernote Editor" ?

![How to remove extra blank space(after/before) from content into the "Summernote Editor" ?](https://www.mindstick.com/mindstickforums/279c329f-63f6-4187-b89d-c5d11c5ebffe/images/d76fb6d3-e407-4836-ab53-1903282c5ac6.png)

This is [Summernote Editor](https://www.mindstick.com/forum/34696/how-to-add-summernote-editor-in-android-studio-project).

## Replies

### Reply by Aryan Kumar

Sure, here is how you can remove extra blank space (after/before) from content into the "Summernote Editor" in ASP.NET MVC:

1. First, you need to install the Summernote: https://summernote.org/ editor in your ASP.NET MVC project. You can do this by adding the following NuGet package to your project:

Code snippet

```plaintext
Install-Package Summernote
```

1. Once the Summernote editor is installed, you need to add the following code to your view:

Code snippet

```plaintext
<summernote id="summernote" height="400"></summernote>
```

1. Next, you need to create a controller action that will be used to handle the POST request from the Summernote editor. The following code shows an example of a controller action that can be used to remove extra blank space from the content:

Code snippet

```plaintext
public ActionResult RemoveExtraBlankSpace(string content)
{
  // Remove extra blank space from the content.
  content = content.Trim();
  content = content.Replace("\n\n", "\n");
  content = content.Replace("  ", " ");

  // Return the updated content.
  return Content(content);
}
```

1. Finally, you need to update your view to call the RemoveExtraBlankSpace() controller action when the user clicks the "Save" button. The following code shows an example of how you can do this:

<summernote id="summernote" height="400"> <script> $(document).ready(function() { $('#summernote').summernote({ onfocus: function() { // Get the content of the Summernote editor. var content = $(this).summernote('code');

Code snippet

```plaintext
      // Call the `RemoveExtraBlankSpace()` controller action to remove extra blank space from the content.
      $.ajax({
        url: '/RemoveExtraBlankSpace',
        data: { content: content },
        type: 'POST',
        success: function(response) {
          // Update the content of the Summernote editor with the updated content.
          $(this).summernote('code', response);
        }
      });
    }
  });
});
```

Once you have added this code to your project, you can test it by opening the view in a browser and clicking the "Save" button. The Summernote editor will remove any extra blank space from the content and save the updated content.


---

Original Source: https://www.mindstick.com/forum/55138/how-to-remove-extra-blank-space-after-before-from-content-into-the-summernote-editor

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
