Format a portion of the text within a Textbox in .NET C# ASP.NET to appear in

In my .NET C#/Aspx web application, users fill out fields and the resulting form is sent via email. A new requirement has come up to allow users to highlight text and apply formatting such as bold or color.

After some research online, it seems that using JavaScript might be the most suitable option for this task. However, I encountered an issue where the inserted HTML tags do not render within the textbox. I understand that this is a limitation of the ASP.NET textbox, but I'm wondering if there's a way around this?

<script type="text/javascript"> 

function formatText(tag) {
    var selectedText = document.selection.createRange().text;

    if (selectedText != "") {
        var newText = "<" + tag + ">" + selectedText + "</" + tag + ">";
        document.selection.createRange().text = newText;
    }
} 

Answer №1

In order to edit text with enhanced features, a robust tool such as ckeditor is required.

Answer №2

Instead of starting from scratch, consider using a feature-rich text editor such as TinyMCE. You can customize it to only include basic options like bold or italic for the user.

For guidance on creating a straightforward example, check out this resource:

How to Easily Create a Simple TinyMCE WYSIWYG Editor

Answer №3

It is not possible to accomplish in a standard Textbox. Consider using a RichTextEditor like CKEDITOR or CLEEDITOR.

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

What could be causing an external row to be inserted during the process of writing an excel file in Nodejs?

Currently, I am tackling the challenge of utilizing Nodejs to read and write Excel files with the "XLSX" npm module. While I have managed to successfully read and write data, an unexpected external row is being inserted in place of the first row with the c ...

Plugin combination of Cordova File, InAppBrowser, and File Opener

I am experiencing an issue with opening a PDF file that I have stored using the File Plugin. I have tried using both the InAppBrowser and File Opener Plugin, but neither seem to work. I am currently using the Visual Studio Emulator KitKat for Android. Whe ...

What is the method for applying multiple criteria to filter an array in Vuejs?

const app = new Vue({ el: '#app', data: { search: '', itemsList: [], isLoaded: false, selectNum: status, userList: [{ id: 1, name: "Prem", status: "ok" }, { id: 2, ...

Preventing browser history with Html.TextBoxFor

I have successfully integrated a jQuery calendar picker that opens when a user clicks on a textbox. However, there seems to be an issue with input history overlapping part of the calendar display. Is there a way to disable or hide this history feature? CO ...

Bringing PlayCanvas WebGL framework into a React environment

I am currently working on integrating the PlayCanvas webGL engine into React. PlayCanvas Github Since PlayCanvas operates on JS and the code remains in my index.html file, I am facing challenges in comprehending how it will interact with my React compone ...

What could be causing the video not to display in landscape mode on the iPad Pro?

I'm having an issue with a standard HTML5 <video> on my website. The videos are working fine on most devices, however there is a problem specifically with the iPad Pro in landscape orientation. It seems to work properly in portrait orientation ...

I am experiencing difficulty in passing parameters to nested navigators

I have developed a TechInfo page and a ProfileInfo page. The ProfileInfo Page is nested inside a Drawer Navigator. I want to display some information from the TechInfo page and some from the ProfileInfo page when I enter our info and press a button. Howeve ...

Having trouble viewing PDF files after uploading them to S3. Uploading images is working without any issues in NodeJS

For a while now, I've been using the aws-sdk to upload images with no issues. However, I recently tried to upload a PDF and encountered a problem. Even though the upload seems successful, I get an error message saying Failed to load PDF document. I a ...

Managing data in an Angular Material table and dialog for creating, reading

Currently, I am struggling with implementing a CRUD method using angular material table and dialog components. I am facing difficulties in understanding how to update records using the dialog and pass data between components. Despite my efforts, the modif ...

Vuetify: Dynamic v-select options based on user selection

Here's a codepen I created as an example: https://codepen.io/rasenkantenstein/pen/qBdZepM In this code, the user is required to select a country and then choose cities only from that selected country. The data of people is stored in an array behind t ...

Issues with Lucene.net preventing search results from displaying

In my possession are 8 text files, each containing approximately 5 million rows of encoded data. -Path allocation to DEV\svcInformational_1_7 via document #12478901 has been completed. Path TRNS_Legacy_773 assigned with type TRNS_Legacy. Currently, t ...

Exploring the concept of generator functions in ES6

I'm grappling with understanding JS generators and why the asynchronous operations in the example below are returning undefined. I thought that using yield was supposed to wait for asynchronous calls to finish. function getUsers(){ var users; $.aj ...

Troubleshooting Guide: Resolving the "No parameterless constructor defined for this object" error in your AngularJS/MVC application

I have a complex CRM page where users can schedule classes that they attend and learn from. The process involves filling out fields in a Modal and clicking Save, which then gathers the data and passes it to C#. However, in this particular instance, I&apos ...

Suggestions for managing AngularJS within ASP.NET Web Forms?

Recently, I integrated AngularJs into a website that is built with asp.net webforms. I discovered that when using ng-Submit on a button, the form also triggers a Post call. How can I prevent the form from automatically submitting so that Angular can perf ...

Handling OnClick events in D3 with Websocket Integration

My goal is to implement a Websocket in JavaScript that transmits a variable obtained when clicking on a node in a D3 chart. While I have made progress using static data, I'm struggling with initiating the code upon node click to retrieve the "user inf ...

Issue with Angular filtering when utilizing pipe and mapping the response

Code snippet from shop.service.ts getProducts(brandId?: number, typeId?: number) { let params = new HttpParams(); if (brandId){ params = params.append('brandId', brandId.toString()); } if (typeId){ params = params.append('typeId', ...

Creating a distinctive appearance for JavaScript's default dialogue box

Is there a way to enhance the design of my code that prompts the user for input using JavaScript's `prompt`? Currently, it appears too simplistic. Are there any CSS or alternative methods to improve its appearance? function textPrompt(){ var text = ...

Questions about ASP.NET ReportViewer and Linq To Sqlinquiring about ASP.NET Report

Is it possible to use the asp.net ReportViewer control with LinqDataSource? Are there any available examples of this integration? Why do Linq to Sql entity classes generated by not appear in the Website Data Sources pane when editing a report? ...

Addressing memory leaks in React server-side rendering and Node.js with setInterval

Currently in my all-encompassing react application, there's a react element that has setInterval within componentWillMount and clearInterval inside componentWillUnmount. Luckily, componentWillUnmount is not invoked on the server. componentWillMount( ...

Looping through and printing JSON strings

Currently, I am dealing with a JSON string of this specific format: {"prey":["{\"distance\": 8.686924173343307, \"signal\": \"-59\", \"frequency\": 2447, \"mac\": \"00:00:00:00:00:00\", \"ip ...