[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 824
  • Last Modified:

How can I allow html in textbox.

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
designaire
Asked:
designaire
  • 3
  • 3
2 Solutions
 
AanvikCommented:
instead of this you should use Literal control. It should be able to handle this.


0
 
Muhammad Ousama GhazaliSolution Analyst & ArchitectCommented:
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
 
designaireAuthor Commented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
designaireAuthor Commented:
What's Literal control?
0
 
designaireAuthor Commented:
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
 
AanvikCommented:
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

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!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now