.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> Silverlight >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Perform Filter in TextBox In Silverlight

Posted By:Diptimaya Patra       Posted Date: April 01, 2010    Points: 25    Category: Silverlight    URL: http://www.dotnetspark.com  

Filter in TextBox In Silverlight 3. In this article we will see how we can filter a Textbox on Keyboard inputs. We will see how we can block Numeric input from Keyboard.
 

Introduction

In this article we will see how we can filter a Textbox on Keyboard inputs. We will see how we can block Numeric input from Keyboard.

Creating Silverlight Project

Fire up Visual Studio 2008 and create a new Silverlight 3 Project. Name it as FilteredTextBox.

1.gif

Add a TextBox to the Application.

Our aim is to block the Numerical key inputs, so have a event handler for KeyDown for the TextBox and add the following code in place.

private void txtNumericFiltered_KeyDown(object sender, KeyEventArgs e)
{

    switch (e.Key)
   {

        case Key.D0:

        case Key.D1:

        case Key.D2:

        case Key.D3:

        case Key.D4:

        case Key.D5:

        case Key.D6:

        case Key.D7:

        case Key.D8:

        case Key.D9:

            e.Handled = true;

            break;

        default:

            break;

    }
}


That's it. Run your application to test it.

If you press any numeric value and special characters associated with it won't be typed. Anything else is allowed.

Hope this article helps.
 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend