Xpode.com        Click here to Print this article.

.NET Interview questions: - If a validation is very complex what will you do?

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"

ControlToValidate="txtNumber"

OnServerValidate="ServerValidate"

ClientValidationFunction="CheckZero" /><br>

Input:

<asp:TextBox id="txtNumber" runat="server" />

<script language="javascript">

<!--function CheckZero(source, args) {

int val = parseInt(args.Value, 10);

if (value==0) {

args.

IsValid = false;

   }

}

// -->

</script>


Above is the .NET interview questions & also see the following video on IL code, CLR, CTS, CAS: -



http://
http://www.questpond.com/

Contributed by:
Shivprasad koirala Koirala
I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small E-learning company in India. We are very much active in making training videos , writing books and corporate trainings. Do visit my site http://www.questpond.com for .NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers

Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=702

Click here to go on website