Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3301872
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:47:41+00:00 2026-05-17T20:47:41+00:00

I made a function to truncate a string in the code behind file. But

  • 0

I made a function to truncate a string in the code behind file. But how do i use it in the aspx file?

This is the textbox:

<asp:TemplateField HeaderText="page" HeaderStyle-Wrap="true">
    <ItemTemplate>
        <a href='<%# makepageURL( Eval("page") )%> '>
            <%# Eval("page")%>
        </a>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:TextBox ID="txtpage" TextMode="SingleLine" Rows="1" Width="100%" runat="server" Text='<% #Bind("page") %>' />
    </EditItemTemplate>
</asp:TemplateField>

And this is my function:

Public Function TrimString(ByVal Value As String, ByVal Length As Integer) As String
    If Value.Length > 20 Then
        Return Value.Substring(Value.Length - (20 - 3)) + "..."
    End If

    Return Value   
End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:47:41+00:00Added an answer on May 17, 2026 at 8:47 pm

    It’s not an issue of how to use it, but actually when to use it?

    If you had a regular span, you could do this:

    <span><%: TrimString("somestring") %></span>
    

    But this is a TextBox your dealing with (user input).

    When should it truncate?

    On Form Submit? (that would make sense).

    As they type (well then you’d need to use JavaScript).

    By the looks of your code snipper, your using a FormView.

    So i wouldn’t be calling it from the ASPX (which the equivalent of executing code during Page Render), i would be calling it during the Edit/Submit event, server-side event handler.

    In other words, truncate the value the user put in, after they have submitted the form and before you persist to the database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone got a ready made function that will take an XML string and return
I made a function like this (no need to write the whole function here)
I have made a function to convert a textbox value to date. I want
When i made this function: function makeThumbnail($type, $name, $size, $tmp_name, $thumbSize) { //make sure
I have made strstr() function but the program does not give any output,just a
As I understand the doc, ParseDouble function made something like : Double parseDouble(String s)
I made this function and need some help sorting out the logic flow. It
Edit: With the answer given I made this function function grabclosestcolor($r, $g, $b){ $colors
I made this function, the same result get printed twice. Any idea why? is
ReSharper likes to point out multiple functions per ASP.NET page that could be made

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.