Validating the textbox in c#.net
<p>hi i want to set my text box only with the alphabets i have tried the following code, it's working fine for the keyboard keys.but if i press the numpad key numbers it is accepting numbers can anyone please help me, much appreciated thanks.</p>

<pre><code>bool isvalid = true;

    private void textBox1_KeyDown(object sender, KeyEventArgs e)
    {
        if ((e.KeyValue &lt;65 || e.KeyValue &gt; 90) &amp;&amp; (e.KeyValue&lt;97||e.KeyValue&gt;122) e.KeyValue != 8))
        {
            isvalid = false;
            MessageBox.Show("only alphabets");

        }
        else
        {
            isvalid = true;

        }
    }

    private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
    {
        if (isvalid == false)
        {
            e.Handled = true;
        }
        else
        {
            e.Handled = false;
        }

    }
</code></pre>
