SixString Posted January 22, 2004 Posted January 22, 2004 Hi ;) Can anyone help me with this line of code ..so it will be abble to use on CodeBehind Or anyone as a better way of making this happen??? Thanks in advance <% FUNCTION CropSentence(strText, intLength, strTrial) Dim wsCount Dim intTempSize Dim intTotalLen Dim strTemp wsCount = 0 intTempSize = 0 intTotalLen = 0 intLength = intLength - Len(strTrial) strTemp = "" IF Len(strText) > intLength THEN arrTemp = Split(strText, " ") FOR EACH x IN arrTemp IF Len(strTemp) <= intLength THEN strTemp = strTemp & x & " " END IF NEXT CropSentence = Left(strTemp, Len(strTemp) - 1) & strTrial ELSE CropSentence = strText END IF END FUNCTION %> <% =(CropSentence((DataBinder.Eval(Container.DataItem, "descrabrv").Value), 100, "...")) %> Quote
Administrators PlausiblyDamp Posted January 22, 2004 Administrators Posted January 22, 2004 not tested but a quick port to vb.net Function CropSentence(ByVal strText As String, ByVal intLength As Integer, ByVal strTrial As String) As String Dim wsCount As Integer Dim intTempSize As Integer Dim intTotalLen As Integer Dim strTemp As String Dim arrTemp() As String wsCount = 0 intTempSize = 0 intTotalLen = 0 intLength = intLength - Len(strTrial) strTemp = "" If strText.Length > intLength Then arrTemp = strText.Split(" ") For Each x As String In arrTemp If strTemp.Length <= intLength Then strTemp = strTemp & x & " " End If Next Return strTemp.Substring(0, strTemp.Length - 1) & strTrial Else Return strText End If End Function Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
SixString Posted January 22, 2004 Author Posted January 22, 2004 Hey i had a sugestion from an expert ... <code> Public Function CropSentence(title, maxlength, pad) If title.length < maxlength Then Return title Else Return title.Substring(0, maxlength) & pad End If End Function </code> how do i set it to work with something like this : <code> <asp:TemplateColumn> <ItemTemplate> <asp:TextBox class=conteudotd id=TextBox2 runat="server" BorderStyle="None" BorderWidth="0" Rows="0" Columns="0" Enabled="true" ToolTip="Descrição" ReadOnly="True" MaxLength="20" TextMode="MultiLine" Text='<%# DataBinder.Eval(Container.DataItem, "descrabrv") %>' Height="45" Width="400"></asp:TextBox> </ItemTemplate> </asp:TemplateColumn> </code> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.