0

Based on the drop down selection the text box should be validate in C# textbox_TextChanged event. If drop down selection value is 1 it allows characters and if 2 it allows numbers only.

halfer
  • 19,824
  • 17
  • 99
  • 186

2 Answers2

0

I would use Int32.TryParse to validate the integer input

Here's a link to an example of its usage http://msdn.microsoft.com/en-us/library/f02979c7(v=vs.110).aspx

TGH
  • 38,769
  • 12
  • 102
  • 135
0

You can add a compare validator to the textbox, in the compare valudator change de operator to check type and in datatype add integer. This control can be enable or disable instead us using a server aide event you can use javascript to enable the validator when necesarry.

Im this question you can find information on how to enable or disable the validator Disable ASP.NET validators with JavaScript

You can use jquery to get the value of the dropdown more easy. If the dropdown is a server side element use in the selector the nameofcontrol.clientid to get the correct name of the control.

Community
  • 1
  • 1
Juan
  • 1,352
  • 13
  • 20
  • how to validate it allows only alphabets by using compare operator – user2979084 Nov 14 '13 at 07:38
  • Hi if you want to validate only alphabets you may better use a regular expression validator. You have to find or create a validation expression that better fit your requirements. – Juan Nov 14 '13 at 13:50