Sure, here is how you can remove extra blank space (after/before) from content into the "Summernote Editor" in ASP.NET MVC:
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
Install-Package Summernote
Once the Summernote editor is installed, you need to add the following code to your view:
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
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);
}
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
// 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.
Liked By
Write Answer
How to remove extra blank space(after/before) from content into the "Summernote Editor" ?
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy
Join MindStick Community
You have need login or register for voting of answers or question.
Aryan Kumar
18-Jun-2023Sure, here is how you can remove extra blank space (after/before) from content into the "Summernote Editor" in ASP.NET MVC:
Code snippet
Code snippet
Code snippet
<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
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.