You find that one of your validations is very complicated and does not fit in any of the validators, what will you do?

 Posted by ArticlesMaint on 9/16/2009 | Category: ASP.NET Interview questions | Views: 3331

Answer: -
Best is to go for CustomValidators. Below is a sample code for a custom validator, which checks that a textbox should not have zero value
<asp:CustomValidator id="CustomValidator1" runat="server"
ErrorMessage="Number not divisible by Zero"
ClientValidationFunction="CheckZero" /><br>
<asp:TextBox id="txtNumber" runat="server" />
<script language="javascript">
<!--function CheckZero(source, args) {
int val = parseInt(args.Value, 10);
if (value==0) {
IsValid = false;
// -->

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response