Link to home
Start Free TrialLog in
Avatar of digital_soul
digital_soul

asked on

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

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
ASKER CERTIFIED SOLUTION
Avatar of Mrugesh1
Mrugesh1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Alpesh Patel
Please replace this part in dataset from where you are getting from.