Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How can I retain linebreaks in a bound Literal control in Encode Mode?

Posted on 2011-04-20
3
Medium Priority
?
544 Views
Last Modified: 2012-05-11
Hi Experts

I am binding data from a database to a Literal Control with Mode set to Encode as the data is user generated, to ensure no script code can be rendered. Line breaks in the data are not being rendered and I need to be able to ensure they are.

Previously I would have done something like the following in a bound label Control

Text='<%# Eval("Text").ToString.Replace(vbCrLf,"<br />") %>'

But this is giving me the error '''object.ToString()' is a 'method', which is not valid in the given context"

Presumbaly any attempt to replace with a <br /> tag will not work anyway when the Mode is set to Encode, so how can i do it?

Thanks

Stewart
0
Comment
Question by:digital_soul
3 Comments
 
LVL 3

Accepted Solution

by:
Mrugesh1 earned 1000 total points
ID: 35431481
There were syntax error in your statement. Try below corrected statement.

Text='<%# Eval("Text").ToString().Replace(vbCrLf,"<br />") %>'
0
 
LVL 2

Assisted Solution

by:gcitron
gcitron earned 1000 total points
ID: 35431503
try with () :

Text='<%# Eval("Text").ToString().Replace(vbCrLf,"<br />") %>'
0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 35432326
Please replace this part in dataset from where you are getting from.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month20 days, 21 hours left to enroll

810 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