Escape:Text(txt_content).Length
<%!! Context:CurrentPage.GetElementByName(txt_teaser).Value.Length !!%><%!! Context:Pages.GetPage(Guid:<%inf_PageGUID%>).GetElementByName... !!%>HTML Encoding the string will likely alter its length.
If you were expecting the content to be 100 characters that change will probably not be significant, but when you’re looking for 10 characters encoding an “&” to “&” arbitrarily removes 40% of your capacity.
It should be obvious by now that using a render tag is not the way to solve this problem.
Are you publishing to PHP or ASPX? Use the runtime language support to alter the display on the fly.
Are you publishing to HTML? Use JavaScript.
You’re breaking a walnut with explosives.
--
You received this message because you are subscribed to the Google Groups "RedDot CMS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reddot-cms-use...@googlegroups.com.
To post to this group, send email to reddot-c...@googlegroups.com.
Visit this group at http://groups.google.com/group/reddot-cms-users.
For more options, visit https://groups.google.com/d/optout.
Well, getting the element content via the RenderTag will not alter the length, but HTML encoding it definitely will.
Observe…
"UP & DOWN" - 11 characters
"UP& DOWN" - 24 characters
Your solution is much better than Jian’s, though I suspect measuring the length of the string is not really the goal of Neil’s task at all. I expect there is an element on the page that is quite small (physically speaking) and can only accommodate a small amount of content. Measuring the length of the content is a hack often used to swap out a small display element with a larger one that can handle longer text. This is a bad idea for lots of reasons, but chief among them is that characters are not all the same width, so measuring the number of characters does not actually meet the requirement at all, which is (and I’m guessing) to measure the *width* of the characters.
Both 10 characters:
IIIIIIIIII
vs
WWWWWWWWWW
This type of problem is handled much better with CSS (and the client-side code you are clearly not fond of) as the browser knows exactly how wide that content is going to be for the given device/orientation/zoom/font and can make adjustments as appropriate.
At any rate all that is moot as the actual question was about measuring the length of the string.
Neil, if it *HAS* to be done in a render tag, do it Hilmar’s way (assuming you haven’t already).
/R
You received this message because you are subscribed to a topic in the Google Groups "RedDot CMS Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/reddot-cms-users/LkHGVcA8uNY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to reddot-cms-use...@googlegroups.com.
To post to this group, send email to reddot-...@googlegroups.com.
Visit this group at http://groups.google.com/group/reddot-cms-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "RedDot CMS Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/reddot-cms-users/LkHGVcA8uNY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to reddot-cms-us...@googlegroups.com.
To post to this group, send email to reddot-...@googlegroups.com.