Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > limit chracters <%# Eval("SKUDescription") %> View modes: 
User avatar
Member
Member
eagleag-yahoo - 4/16/2009 3:22:18 AM
   
limit chracters <%# Eval("SKUDescription") %>
tryting to limit amout of characters when using
<%# Eval("SKUDescription") %>
in transformation.
Found this
<%# LimitLength("Some example long text", 10 , "...") %>
but couldnt put it together with EVAL.

Any suggestions?

thanks

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 4/22/2009 7:15:28 AM
   
RE:limit chracters <%# Eval("SKUDescription") %>
Hello,

Could you please try to use following sample code:

<%# LimitLength(Eval("SKUDescription"), 10 , "...") %>

Best Regards,

Martin Dobsicek

User avatar
Member
Member
eagleag-yahoo - 4/26/2009 5:45:18 AM
   
RE:limit chracters <%# Eval("SKUDescription") %>
Thanks, this does work but not when adding to existing code.

what is the difference between:

<%# HTMLEncode(ResHelper.LocalizeString(Convert.ToString(Eval("SKUName")))) %>


and

<%# LimitLength(Eval("SKUName"), 10 , "...") %>

not meaning that linitLength works in second one, but what is diff in rendering or anything else?

thanks



User avatar
Kentico Support
Kentico Support
kentico_jurajo - 4/28/2009 7:50:05 AM
   
RE:limit chracters <%# Eval("SKUDescription") %>
Hi,

If you will use the LimitLength in some HTML code, it can happen that the HTML code will be corrupted. The HTMLEncode method ensures that the returned value is valid HTML code so it won't corrupt e.g. the design, etc.

Best Regards,
Juraj Ondrus