How to check whether we enter integer value in textbox [Resolved]

Posted by Srinibaschampati under C# on 8/30/2013 | Points: 10 | Views : 1748 | Status : [Member] | Replies : 2
How to check whether we enter integer value in textbox




Responses

Posted by: Satyapriyanayak on: 8/30/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
int i;

bool isValidInteger = int.TryParse(textBox1.Text, out i);

if (!isValidInteger)
{
MessageBox.Show("Not a valid integer. Please enter once more");
textBox1.Focus();
return;
}
else
{
MessageBox.Show("valid integer");
textBox1.Focus();
}
}
}
}


If this post helps you mark it as answer
Thanks

Srinibaschampati, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 8/30/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
http://chikkanti.wordpress.com/2012/12/21/how-to-check-whether-entered-value-in-textbox-is-string-or-integer-in-asp-net-c/

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Srinibaschampati, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response