Posts

Web scraping through WebBrowser (.Net WinForm Control)

Image
In this post, I am going to explain how it is easy to extract and change the the web-page content through Web-Browser control. The Web-Browser is a Microsoft windows form control and easy to use. This post will explain you how you can use this control for your need. The Web-Browser control is used to display the web-page in your application. The Web-Browser class is a powerful class that give you leverage to manipulate the html code, interact with JavaScript, automate the web scrapping and many more. You can find more about the Web-Browser from MSDN library. The following steps will guide you how to use the Web-Browser. 1.         The first thing that you should do is to create a windows application project. 2.         Add a Web-Browser and two button controls on web form.   3.         Set the “Url” property of the control or you can do this by writing...

Secure your website to be iframed

In this post I am going to explain how you can secure you website from being iFramed. When you are presenting sensitive data on website then you must secure your data from other websites. In order to do this, you need to add a below header on the web server. Header Name – X-Frame options header Options                 Deny – Block all the sites                 Sameorigin – Allow only the sites have same origin.                 Allow-From - Specify list of domain name

List of RSA Key Container names

List RSA key container If you are struggling to get which RSA key installed on your machine then this post will help you in this. There is no straight forward thing that will give you the installed RSA containers names. With the help of below steps you will be able to get the list of installed RSA key container names. So, without wasting any time more let’s jump on the solution. Step 1. Open visual studio IDE and create a console application Step 2. Add “ using  System.IO; ” namespace to the program class Step 3. Add below code in Main method var  files = System.IO. Directory .GetFiles( @"C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\" );              foreach  ( var  f  in  files)             {                  // try catch is ...

Microsoft Fakes Framework - Shim

Image
I was writing the unit test cases using the Microsoft Fakes framework so thought to share my knowledge with you all. I majorly used Shim to write my test cases, so this post mostly focuses on Shim. I will write another post on Stub in coming days. As most of you know that this is not the only one framework in market to write fake unit test cases the advantage of using this framework on the other is that you have full control on the test case. It will allow you to test your test case if some part of the application is not ready. Why to use Shim? The basic question will come in your mind that why to use Shim not the Stub. For me both are same and depend on the design of your application. If you are using any design pattern in your application except singleton then it will be advisable to use the Stub because it work very well with “Interfaces” and it is clearly mentioned in the Microsoft site as well. Shim basically reduces the burden from the compiler by not maki...

Allow only numbers/decimal in input box

If your requirement is to allow only numeric and decimal numbers in input box using the vanilla javascript then this post will help you in this. Let’s get started Step 1 – HTML Code < input   id ="txtWinAmt"   type ="text"   class ="inputbox"   style =" width : 60px ;  height : 19px ; line-height : 1px"   oninput =" ValidateInputIsNumber( this ) "   /> Step 2 – javascript code     var regEx = new RegExp(/^\d*\.?\d*$/);     var lastValid="";     function ValidateInputIsNumber(controlId)     {         if(controlId.value.length==1)             lastValid="";         if (regEx.test(controlId.value))             lastValid = controlId.value;         else             controlId.value = lastValid;     }

Checkbox list in ASP.Net MVC

Image
Recently, I got an assignment when I need to show the items in checkbox list format. It was very easy in ASP.NET web form because it has CheckBoxList control but it was bit challenging for me to show the items in checkbox list in ASP.NET MVC as there are basic controls available. In this post I am going to explain you how to build the CheckBoxList control in ASP.NET MVC using the basic control and Razor engine following the steps listed below. Let’s get started Step 1. First thing first, View Code @model  SOW.Models. DropdownValues      < table >          < tr >              < td   class ="td_12per"> Select Country: </ td >              < td   class ="td_12per">              ...

jsGrid

Image
I was working one a Asp.Net MVC application where I was using the Web Grid to display the data based on the selected search criteria. It was working great but client asked me to use the jsGrid instead of Web Grid as it has many ready to use features like (Edit, Delete, Search, etc..).  Initially, jsGrid gave me very hard time to display the data in it but after few hit and trial I manage to display the data. After spending couple of hours on jsGrid, I started liking it. In this article, I am going to explain how to use the jsGrid to display the data and some other tactics in very easy steps. I am building the application in ASP.NET MVC. Step 1. Content delivery network (CDN) of jsGrid and jQuery libraries are as below https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid.min.css https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid.css https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid-theme.min.css https://code.jquery.com/jquery.min.js ...