RE: How to create a label which only displays a certain amount of characters?

Tech-Archive recommends: Fix windows errors by optimizing your registry

v-jetan_at_online.microsoft.com
Date: 03/04/04


Date: Thu, 04 Mar 2004 06:13:53 GMT


Hi Daniel,

Thank you for posting in the community!

Based on my understanding, you want the WebForm Label control to only
display certain amount of characters.

=====================================
I think you should inherit the Label class and override the Text property.
As you said, this does not work as you expected, can you show me how you do
with your Text property? Why it does not work as you expected?

I think you may do like this(Suppose you only want to display the Text's
length less than 8 ):
public class WebCustomControl1 : System.Web.UI.WebControls.Label
{
        public override string Text
        {
                get
                {
                        return base.Text;
                }
                set
                {
                        if(value.Length<=8)
                        {
                                base.Text=value;
                        }
                        else
                        {
                                this.Page.Response.Write("The value you set is greater than 8!");
                        }
                }
        }

}

=====================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.



Relevant Pages

  • Re: Audio Innovations silver speaker cable
    ... However many of us prefer to display the postings ... posting, in order to be able to read discussions in chronological order. ... Thus it isn't really a matter of what is possible. ... Audio Misc http://www.st-and.demon.co.uk/AudioMisc/index.html ...
    (uk.rec.audio)
  • Re: help!! How do I block emails?
    ... You haven't concealed your address in this posting, ... The E-mail address will be displayed on the Properties display. ... might explain the increased Spam which you've seen. ... left-click Accounts ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: FT77/757/767 display possibly needed !!
    ... > Top posting makes it easier to read the reply.. ... > Ok i have checked for dry joints and not a sausage.. ... If it's is a gas discharge display, ... If nothing shows up, check a few voltages. ...
    (uk.radio.amateur)
  • Re: More on VRAMs
    ... A follow-up to my last posting. ... The error message is "The currently selected display resolution is ... Dan the K wrote: ... > have arrows going all the way out. ...
    (comp.sys.ibm.ps2.hardware)