Posts

Showing posts from March, 2021

Validate that a certain checkbox is checked before submit(ASP.NET MVC)

Image
Introduction In this article we will discuss different approaches of performing validation on a checkbox value to be true in an MVC view.This validation should combine security and be user friendly as well Prepare Scenario 1.Create an MVC application as in the following pictures(name it ApproachForValidatingAcheckbox for example)    2.Add a new class under model folder as follows //////////////////////////////////////////////////////////////////////////////////////////////////////////////////  public class UserAgreementModel     {                   } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 3.Add a controller class under controllers folder as follows 4.Add a view for submitting an instance of the model as follows   place the following code in the view ////////////////////////////////////////////////////////////////////////////////////...

An example of a (LINQ) approach to solve recurring problems

 Introduction Most of the time,we think about LINQ in terms of querying the data model . However ,it can give a set of alternative solutions to problems that we just drill in in a very primitive and basic way.That is because it is used to perform operations on generics of any data type. Problem One task I handled lately was to find the gap in a series of numbers.Let us discuss the first solution that comes into one's mind when he approach the task at the first stage. First Solution To be able to follow the discussion.create  a .NET console application and copy the below code  inside program.cs class file //################ using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; namespace NumberSeriesGapFinder {     class Program     {         static void Main(string[] args)         {             string inputNumbers;       ...