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 6734897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:56:38+00:00 2026-05-26T10:56:38+00:00

I am working on a silverlight web app. It interacts with a module that

  • 0

I am working on a silverlight web app. It interacts with a module that sends SMS’s. I want to limit the text to 160 and show a counter. I did it like this:

public partial class SendSMSView
{
    public SendSMSView()
    {
       InitializeComponent();
       ApplyTheme();
    }

    protected void tbMessage_KeyDown(object sender, KeyEventArgs e)
    {
        count = 160 - this.tbMessage.Text.Length;
        this.lblCount.Content = count.ToString();
    }
}

This works fine for all the keys except backspace and delete. Of course it is made to function like this. i dug more on this and tried overriding keydown event so i added the following code snippet:

public class CustomTextBox : TextBox
{
    public CustomTextBox(): base()
    {
    }

    protected override void OnKeyDown(KeyEventArgs e)
    {
        e.handler=false;
        base.OnKeyDown(e);
        //this place
    }
}

In OnKeyDown function i get all the key strokes registered. Setting Handler to false here doesnt help and still i cant get backspace to trigger tbMessage_KeyDow.

I want to somehow call the tbMessage_KeyDow function from //this place forcefully from there for backspace.

I searched MSDN, and found that IsInputKey can be overriden to return true so that onKeyDown responds to it as well, but My framework neither has IsInputKey nor PreviewKeyPress. Is there a workaround for getting backspace key registered as input key, or to call tbMessage_KeyDow [which is very crude approach] ? Please help.

  • 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-26T10:56:38+00:00Added an answer on May 26, 2026 at 10:56 am

    try this ….

    If you want to detect the backspace key on the key pressed in a textbox. we would suggest that you can try to do in the textbox’s KeyUp event instead of the KeyDown event.
    for example:

       <TextBox x:Name="txt" KeyDown="txt_KeyDown" Text="Hello" KeyUp="txt_KeyUp"></TextBox>    
    

    the codebehind:

        private void txt_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Back)
            {
                MessageBox.Show(this.txt.Text);
            }
        } 
    

    or you can do like this…by creating a user control….

    public partial class Page : UserControl {
    
        private TextBox TextBox1;
    
        public Page() {
            InitializeComponent();
            TextBox1 = new TextBox();
            Width = 300;
            Height = 100;
            LayoutRoot.Children.Add(textbox);
            OnTextChanged(((object)(sender)), ((TextChangedEventArgs)(e)));
            TextBox1.TextChanged;
            if (e.Key == Key.Back) {
                e.Handled = true;
            }
            else if (e.Key == Key.Delete) {
                e.Handled = true;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a Silverlight web application that creates PDF documents. We want
I am working on a silverlight app that you need to enter information into
I'm working on a Silverlight app that would allow a user to upload a
I am working with a silverlight app that has a fairly large appsettings section
We have a Logitech web cam that we want to get working with .NET.
I've got a Silverlight app that I want to call from either https or
I am working on a Silverlight v3 web app and I would like to
I am developing a Silverlight web app and am working now on a child
I am working on a Silverlight client and associated ASP.NET web services (not WCF),
I've been working in Silverlight recently and I've slowly been discovering that as simple

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.