This topic is locked
[SOLVED]

 Switch between html & text view

1/23/2011 6:18:28 PM
ASPRunnerPro General questions
W
waynes888 author

Is there a way to display a field as text if it is a text or with html view if it contains html? the reason whys is I store emails sent from the system, some are plain text while others are html emails. If I set the view to html then the HTML displays fine but the text view doesn't & the same for the reverse.
alternatively how do I update a value before it is displayed on the view page, I have tried the following but neither works:
values("message") = asp_nl2br(values("message"))
and
xt.assign "message", asp_nl2br(values("message"))
According to help for display page you use the beforedisplay event "to modify the value of any template variable or to define a new one" but how?

Sergey Kornilov admin 1/24/2011

I guess you can use 'View as' type 'Custom' and apply your code there. The main question is how you find if field contains plain text or html.

W
waynes888 author 1/24/2011



I guess you can use 'View as' type 'Custom' and apply your code there. The main question is how you find if field contains plain text or html.


It's easier enough to check if the text contains html by just searching for tags but how do you modify the view to display either text or html?
I have a workaround for now but converting the text to html before I store it that way I don't need to check it but I would like to know the answer to the second part of the question and that is how can values be modified before they are displayed? The methods I used don't seem to work.

Sergey Kornilov admin 1/24/2011

Set 'View as' type to 'Custom' and use something like this:

if bTextField then

strValue = asp_nl2br(strValue)

end if


This is it. Text value will be converted, html value will be displayed as is.

W
waynes888 author 1/29/2011



Set 'View as' type to 'Custom' and use something like this:

if bTextField then

strValue = asp_nl2br(strValue)

end if


This is it. Text value will be converted, html value will be displayed as is.


Thanks