How can i compare an integer value with a string variable?

  • Thread starter Thread starter Vaj
  • Start date Start date
V

Vaj

Hi,
when i'm Validating the Age TextBox like this
if(txtAge.Text>125) reqage.ErrorMessage="age should be less than 125";

[reqage--its a requiredfieldvalidator, txtAge.Text contains only integer values ].

I'm getting an errormessage "cannot use > to compare a string with an integer value.

Can anyone help me to solve this pblm?

thanks ,
Vaj.
 
You must convert it to number. Use following code.

int.Parse(txtAge.Text)>125

Vlado
Hi,
when i'm Validating the Age TextBox like this
if(txtAge.Text>125) reqage.ErrorMessage="age should be less than 125";

[reqage--its a requiredfieldvalidator, txtAge.Text contains only integer values ].

I'm getting an errormessage "cannot use > to compare a string with an integer value.

Can anyone help me to solve this pblm?

thanks ,
Vaj.
 
Back
Top