Solved

How can I allow html in textbox.

Posted on 2009-05-15
7
790 Views
Last Modified: 2012-05-07
I have a database with one entry the client can change. The one entry is going to display on the front page. I want them to be able to use some html code like <b>xxx</b> or make the line of code into a link. I was trying to use just a regular text box but I can't seem to make it read the html code. I can use gridview but it's in such a tight space it pulls apart the design? Is there anyway I can make a regular label or text box read html code, or make the grid view fit in a small place?
0
Comment
Question by:designaire
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 5

Expert Comment

by:Aanvik
ID: 24400477
instead of this you should use Literal control. It should be able to handle this.


0
 
LVL 11

Accepted Solution

by:
Muhammad Ousama Ghazali earned 75 total points
ID: 24400514
TinyMCE is an excellent replacement for HTML based input into a regular textbox used at many sites including the official asp.net forums site and once started it is very easy to setup. Here is the link to its official site: http://tinymce.moxiecode.com/. If you are interested I could help you with sample code to easily setup it.
However, if you wish to acquire HTML from the simple TextBox it is not that difficult but for ASP.NET it is always a security issue. However, if you are comfortable and confident that input is from trusted users, you have to set one property of the page to false in order to let the textbox send HTML contents which may in turn contain malicious content such as script. Hence, the use of some good HTML Editors such as TinyMCE mentioned above which take care of all these problems and let you have a good programming experince while also allow users to have better looking input. TinyMCE's customization is easy and you can restrict users to use only limited formatting options by allowing only a small set of fucntions/images to appear on its toolbar.
Back to the question at hand, the property which needs to be set to False is ValidateRequest. Even though you can set it site wide from web.config it is adviseable to use it at page level only for specific pages which allow HTML input. You can do it in Page Declaration element in ASPX file. Use the sample snippet below (just copy ValidateRequest="False" part and paste it in your page):

<%@ Page ValidateRequest="False" %>

Open in new window

0
 

Author Comment

by:designaire
ID: 24400546
I'll look at the TinyMCE, especially for another page where I have more copy going into a text field.

However, the front page only has one line of type. Maybe I failed to mention it's reading from a database. I already have the Page VlidateRequiest set to false. It's fine when I'm using a GridView and it works but if I use the text box it just displays the text <b>test</b>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:designaire
ID: 24400573
What's Literal control?
0
 
LVL 5

Assisted Solution

by:Aanvik
Aanvik earned 50 total points
ID: 24400580
0
 

Author Comment

by:designaire
ID: 24400593
When I used a Label instead of a text box to display the information from the database it worked. I'll look at both of your suggestions however. Thanks
0
 
LVL 5

Expert Comment

by:Aanvik
ID: 24400656
Label is fine for small html code.. If you need more advance then literal is best. Otherwise label is good for small text as you mentioned.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question