Having difficulty retrieving the InnerHtml from the editor div of the Bootstrap WYSIWYG rich text editor using c#

I have been utilizing the Bootstrap WYSIWYG rich text editor to create HTML email templates. The editor functions perfectly when checked in the browser.

To fetch the HTML contents of the editor div using JQuery, I used $("#editor").html();

In an attempt to retrieve the HTML content on the server side, I included a runat="server" attribute to the editor div. However, I am facing difficulties in fetching the HTML content on the server side.

I even tried storing the HTML content in a hidden field and accessing it on the server side, but unfortunately, that also did not work out :(

Any suggestions from anyone out there?

Answer №1

My solution involved setting the value of a hidden field and then retrieving that value from the server side.

<asp:HiddenField ID="hdnBody" ClientIDMode="Static" runat="server" />

<script>
    function GetEmailID() {
        var emailIDs = $(".search-choice span").text();
        var bodyHtml = $("#editor").html();

        $("#hdnBody").val(bodyHtml);
        $("#hdnEmailIds").val(values);           

    }
</script>

In the server side code:

 string body = hdnBody.Value;

Appreciate your help!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Learn how to incorporate a YouTube video into your website without using Flash or JavaScript by utilizing a popup window

I am in search of assistance with coding for my website to include a video popup feature featuring a YouTube video. I prefer the use of HTML5 rather than Flash or JavaScript. Unfortunately, I have been unable to locate any suitable code examples. While I ...

Javascript unable to retrieve values from variables in AJAX modal form

I've recently started learning about AJAX and been following a tutorial on YouTube. However, I've hit a roadblock in my understanding. I made some adjustments to the code based on what I learned. The following button retrieves the project ID tha ...

Can someone clarify the meaning of (e) in Javascript/jQuery code?

Recently, I've been delving into the world of JavaScript and jQuery to master the art of creating functions. I've noticed that many functions include an (e) in brackets. Allow me to demonstrate with an example: $(this).click(function(e) { // ...

Just one div with a unique ID, yet still belonging to the same class as another div

Having an issue with two divs that share the same class but have different IDs. Only the one defined first in the HTML code is visible (see screenshot below showing when leftMenu is created first). https://i.sstatic.net/5Znvg.png Below is the HTML layout ...

"Utilizing jQuery's ajax functionality without the need for setting a specific

Is there a way to track the loading time for any $.ajax calls without having to specifically add Date() each time? I know I can time my $.ajax calls using something like var ajaxTime= new Date().getTime(); $.ajax({ type: "POST", url: "some.php", } ...

When bsg_head(); is inserted into the <head> tag, the content mysteriously vanishes

While working on a Wordpress project, I encountered an issue where adding the code <?php bsg_head(); ?> to the header resulted in all the content disappearing from the page. Surprisingly, the background color change from the stylesheet was still b ...

Ensure the configuration is stored in a safe location where files cannot be accessed through external links

Currently, I am attempting to utilize a configuration file for both a database and rating script. However, the dilemma lies in the fact that the config file is located in this directory: website.com/include/config.php also known as websitename/include/co ...

javascript horizontal text scroll

I am trying to implement horizontal scroll on my app. I have come across several examples, but none of them seem to fit my specific needs. The code snippet below is one that I thought would work, but it's not functioning as expected. Can someone pleas ...

Guidelines on maintaining an active getSelection with JavaScript

I need help figuring out how to change the font size of selected text within a div without losing the highlight/selection when I click a button. Can someone assist me in keeping the text highlighted while also resizing it upon clicking the button? ...

Is it possible to utilize an AJAX request to access a custom JSON file stored locally in order to dynamically generate Bootstrap

I want to create a page featuring Bootstrap 4 cards with an image, title, brief text, and a "read more" button (basically a blog page with a list of posts). The catch is that this all needs to be done without a server, completely locally. Since this is a ...

How to determine if a scrolling action is initiated manually using jQuery

Here is a question that was previously asked long ago: Detect jquery event trigger by user or call by code Despite previous inquiries, a conclusive answer has not been provided (or I may just be inadequate at searching). My query pertains to distinguish ...

Trouble encountered when attempting to download PDF using jQuery

I have encountered an issue while trying to download a PDF using Ajax response HTML. Here is the code I am using: var newPDFAction = function () { $.ajax({ type: "post", url: '{{ route("admin.getCustomerSalesRepTota ...

Retrieving information from an AJAX callback

Is there a way to extract the URLs from PHP data? Here is an example script that may help you achieve this: PHP $query = 'SELECT * FROM picture LIMIT 3'; $result = mysql_query($query); while ($rec = mysql_fetch_array($result, MYSQL_ASSOC)) { ...

Is it possible to create a French flag using only CSS within one div?

What is the semantically correct way to display the French flag using only HTML and CSS? <div id="flag"> <h1>French flag</h1> </div> To represent the French flag with pure CSS (33% blue, 33% white, 33% red), you can use the fo ...

Returning CLR object or HttpResponseMessage in ASP.NET Web API

What is the common practice in Web API when it comes to return types from action methods? Is it more common to return CLR objects like this: public IEnumerable<ContactModel> Get() { return _contactService.GetAllForUser(); } Or do developers pr ...

Obtaining worth from an entity

I have a collection of objects structured like so: [Object { image = "images/item-1.png" , heading = "Careers" , text = "Lorem ipsum dolor sit a...ctetur adipiscing elit." }, Object { image = "images/item-2. ...

Having trouble debugging JavaScript as a beginner? Unable to pull the cookie value and use it as a variable? Let's

Hello everyone, I'm new to coding and have been working on a project. However, I am facing some errors and need help debugging. I have a cookie named "country" with a value of "AZ" that I want to retrieve using JavaScript and use it in my Google Maps ...

The use of a custom padding on a text input with the Bootstrap 3 form-control class can cause the text to be hidden

It seems like the code is working fine in Opera and Chrome, but in Firefox and IE11, the text is getting hidden, which is not very enjoyable. I don't have a Mac, so I can't test it on Safari. You can see the issue in action on this Plunker. I&a ...

Adjust Bootstrap form positioning to be fixed at the bottom of the page

Can anyone provide assistance with positioning this form at the bottom of the page? <form> <div class="form-group"> <input type="email" class="form-control" id="" aria-describedby="emailHelp" placeholder="Enter email"> &l ...

A guide on identifying and listing all the DLLs from the .NET framework that are being utilized

Currently working with .NET Standard Framework 4.7.2 to develop a basic console application. Wondering if there is a method to automatically copy all required DLLs from the .NET Framework to the output directory, eliminating the need for users to manuall ...