Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > <%# Eval("####") %> define text limit View modes: 
User avatar
Member
Member
gavin - 10/12/2009 7:33:23 AM
   
<%# Eval("####") %> define text limit
Hi

I assume this is straightforward but as i have not figured yet, thought i would put up a post.

When using transformations I sometimes use the expression <%# Eval("####") %>, is there a way of setting the number of characters that are display from this field, similar to how <%# LimitLength("Some example long text", 10 , "...") %> works?

Sorry if this has been posted elsewhere, i have not come across anything.

Thanks

Gavin

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 10/12/2009 1:19:50 PM
   
RE:<%# Eval("####") %> define text limit
Hi,

You can for example use following method in your transformation code:

CMS.GlobalHelper.TextHelper.LimitLength(String, Int32, String)

public static string LimitLength(
string text,
int maxLength,
string padString
)


Example:

<%# TextHelper.LimitLength(Eval("DocumentName").ToString(), 5, "...") %>

Best regards,
Miroslav Remias.

User avatar
Member
Member
gavin - 10/13/2009 3:14:29 AM
   
RE:<%# Eval("####") %> define text limit
Thanks Miroslav

Although having trouble trying to get it working within the transformation

<script type="text/C#" runat="server" >
CMS.GlobalHelper.TextHelper.LimitLength(String, Int32, String)

public static string LimitLength(
string text,
int maxLength,
string padString
)
</script>

<%# TextHelper.LimitLength(Eval("PreText").ToString(), 5, "...") %>


Can you point out where i have gone wrong?

Thanks

Gavin

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 10/13/2009 9:13:20 AM
   
RE:<%# Eval("####") %> define text limit
Hi,

Please just paste following text into your transformation code without any script section:

<%# TextHelper.LimitLength(Eval("PreText").ToString(), 5, "...") %>

Best regards,
Miroslav Remias.

User avatar
Member
Member
gavin - 10/13/2009 9:34:24 AM
   
RE:<%# Eval("####") %> define text limit
Thanks Miroslav although i am still having trouble.

Have added to the current transformation that i am using and an empty one, but get the following error

"[CMSDataProperties.LoadTransformation]: http://server//CMSTransformations/54da185f-d4f9-40dc-a8a6-be1867da4f3e/custom/sowgreen/latestslider.ascx(11): error CS1501: No overload for method 'LimitLength' takes '3' arguments"

Any clues?

Thanks

Gavin

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 10/13/2009 12:15:17 PM
   
RE:<%# Eval("####") %> define text limit
Hi,

This is really strange, could you please let us know what exact version of Kentico CMS are you using and could you also please post here your transformation code (complete code).

Best regards,
Miroslav Remias.

User avatar
Member
Member
gavin - 10/14/2009 4:46:24 AM
   
RE:<%# Eval("####") %> define text limit
Thanks Miroslav

Ok seeing as this is not the norm i will put more detail...

Version is 3.1a

The document type in use is a custom one although putting the standard <%# Eval("####") %> pulls the column details from the DB ok.

Transformation is being used in the stadard 'ScrollingText' webpart - have tried both the transformation below and an empty one.


<div class="slide">

<h5 class="latOrd">
Latest Orders
</h5>
<div class="slidePre">

<%# Eval("PreText") %>
<!--<%# TextHelper.LimitLength(Eval("PreText").ToString(), 5, "...") %>-->

</div>
<div class="slideDate">
Ordered: <%# Eval("Dates") %>
<br />
<a href="~/Latest-Orders.aspx">See more...</a>
</div>

</div>
<div class="slideBott">
</div>


Hope this sheds some light?

Thanks

User avatar
Member
Member
gavin - 10/14/2009 9:01:42 AM
   
RE:<%# Eval("####") %> define text limit
Sorry - Also realised that this question is in the wrong section, initially thought it would not matter but may explain some of the issue. If it can be moved over that would be great

Thanks

Gavin

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 10/14/2009 11:37:16 AM
   
RE:<%# Eval("####") %> define text limit
Hi,

This explains a lot. Since you are using 3.1a version there is different number of parameters in the same function:

public static string LimitLength(
string text,
int maxLength
)

So, please use following code in your transformation:

<%# TextHelper.LimitLength(Eval("PreText").ToString(), 5 ) %>

Best regards,
Miroslav Remias.

User avatar
Member
Member
gavin - 10/15/2009 3:27:21 AM
   
RE:<%# Eval("####") %> define text limit
Thanks Miroslav - apologies for the mistake,

All works a treat.

Thanks for your help.

Gavin