Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 3rd, 2011, 07:09 PM
Authorized User
 
Join Date: Jan 2010
Posts: 31
Thanks: 5
Thanked 2 Times in 2 Posts
Default allowing basic text formatting in a asp.net control

Mainly, how do I allow carriage returns from a textbox control entered in the administration section of my site, which is stored in sql server as nvarchar(max)
I might implement a full wysiwyg at some point but for now, what is the simplest and most secure way to allow line breaks and/or html tags in the text box?
 
Old February 4th, 2011, 02:53 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there

If you have a TextBox with its TextMode set to MultiLine, ASP.NET renders a TextArea which by design allows a user to enter line breaks.

Then when you display the content, you can replace the line breaks with a <br /> element.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
AdamPembs (February 6th, 2011)
 
Old February 6th, 2011, 09:20 AM
Authorized User
 
Join Date: Jan 2010
Posts: 31
Thanks: 5
Thanked 2 Times in 2 Posts
Default

Thanks this code worked

Code:
<asp:Literal ID="L2" runat="server" Text='<%# Replace(Eval("groupdescription"),vbCrLf ,"<br />") %>'></asp:Literal>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting problem while exporting a web page in ms-excel in asp.net using C# Praveenkumar_dsrc ASP.NET 2.0 Professional 1 April 5th, 2009 08:09 AM
Basic concepts with asp.net cool_hari BOOK: Beginning ASP.NET 1.0 1 August 28th, 2006 03:41 AM
table formatting in asp.net balesh ASP.NET 1.0 and 1.1 Basics 1 June 8th, 2006 07:51 AM
'ASP 0131 VBScript not allowing ../ relative addr ruairi Classic ASP XML 3 May 24th, 2006 11:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.