Posts

Showing posts from September, 2018

The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

I was trying to upload a file in client side and sending back the data from the client to Web API controller by angular service . Step 1 : I was doing it by. (It was bot the complete code )   function saveFile(file, cb) {     var readerObj = new FileReader();     readerObj .readAsDataURL(file);     readerObj .onload = function () {         savedFileDataAsBase64Format(readerObj .result, file.name,cb);     };     readerObj .onerror = function (error) {         alert("Error in uploading the file.");     }; Step 2 :     This is my Web api controller action method.        [HttpPost]         [Route("api/FileInput/SaveBase64FileData/{fileName}")]         public void SaveBase64FileData(string fileName, [FromBody]string fileData)         {     ...

What is component in angular.

Image
In this article we will discuss about the component that we are using angular2 application . A angular component mainly consist of three things. 1. Class 2. Template 3. Metadata. We will discuss it one by one . Lets first add a component through Visual studio code. Basically the component is created with .ts extensions and we keep the name as filename.component.ts  . Now we will discuss it one by one. 1. Class : Like other object oriented programming language we declare the class . class is declared with a name and having some property , method and constructor as well. 2. Template :  Template is nothing but an view part of the application . What ever we want to render in the screen that should be mentioned in the template section . Basically the template section contains the HTML content. 3. Metaddata :  Its a extra data used to decorate the angular class for behaving the class properly. Angular2 uses several entries for metadata like annotation...

Some Javascript interview questions.

1. What should be the output of the following code snippet. const arr = [1, 2, 3, 4]; for (var i = 0; i < arr.length; i++) {   setTimeout(function() {     console.log('Index: ' + i + ', element: ' + arr[i]);   }, 4000); } Output :  Index: 4 ,  element: undefined Explanation : Actually the setTimeout function will create a closure function which have access to the upper local variable i . So once the for loop gets executed the setTimeout function is get executed and the i value goes up . So within this 1 sec the i value goes upto 4 and the arr[4] value would be undefined .

Typescript in 5 minutes.

In this article we will simply write a small program in typescript . So if you are a newbie you can follow this program or you can start learning the typescript programming from this article as well. We will do it steps by steps. If you want to know about typescript please visit my blogpost  https://whymysolutions.blogspot.com/2017/09/what-is-typescript.html Step 1 :  To compile a typescript program we must need a typescript compiler and the compiler name is tsc compiler . You can get this in two ways                   . By downloading the npm (by node.js package manager)                   . By typescript's Visual studio plugins By default Visual studio 2017 and Visual studio 2015 update 3 supports typescript . Step 2 :         So for NPM users, to install the typescript npm install  -g typescript  Here g stands for globally  . So aft...

What is .d.ts file .

First of all you should have some idea on Javascript and Typescript as well.  So in this text  ".d.ts"  "d" stands for declarations and "ts" is for typescript file extensions . So here the some points on .d.ts file 1. Basically as per the naming conventions its a declarations file. 2. It can be created from a typescript file or from a Javascript file as well. 3. It act as a interface which contains only the declarations. 4. But conceptually we can say that it is just like a header file in C/C++ . when the third party user will use that file he can have only access to the exported  functions of the declarations file  not to the function  implementations. 5 . This file is get generated while tsc compiler compiled the typescript file and it keppes all the declarations in the .d.ts file and export those . If you want to know more about typescript then you can go through this like https://www.typescriptlang.org/docs/handbook/classes.html . If...

Interface in C#.

Image
Interface is just like a contract. Syntactically it is same with class but fundamentally it is not same with class. Let's see an example. As C sharp does not support multiple interface so we use interface . So interface just contains the declarations  not the implementations .  So in a interface we can declare the method , property and event as  well.  By default an interface members are public. So when a class uses the interface then class should use all the members of the interface and the class should have the function body . So the interface can be used in two ways . 1. Implicitly.   Interface declarations : Interface Implementations: Instantiate Object : 2. Explicit implementations :   So in explicit implementation prefixing the interface name with method name as above. It is used mainly when class is implementing multiple interfaces or interfaces having the same name. So this article is just providing a basic kno...

Angular2 application in Visual Studio Code

Image
In this article we will learn about how to set up Angular2 application in Visual studio code . So we will discuss it step by step. We are not discussing about the typescript , Angular 2 fundamentals or Visual studio code . You must have some basic idea before go through this project set up. Step 1:     First of all we need to install two things    a. node.js (You can download it form here    https://nodejs.org/en/ )    b. Visual studio code ( You can download it from here  https://code.visualstudio.com/download ) So these two things is must necessary for project set up. Step 2: So after installing it you can open the Visual studio code. Yow will see the screen like this.                             Step 3 :  Then please create a folder by clicking on the Open Folder button. Please follow the screenshots. Step 4 : Once you  ...

Default parameters in ES6 functions.

         ES6 is called ECMA Script2015 . As we know we do not have options in ES5 to declare the default parameters . So in ES5 we make the things like this var demo = function(name, address){ var name =  name || "John"; var address = address || "USA"; // Code } But in ES6 we can declare the default parameters like  var demo = function (name = 'John', address = 'USA' ) { // So here we can use the parameters directly. } Please  like this article if it really helped you . 

Toggled pin status is not working in Visual studio.

Image
Those who are working on Visual studio IDE they might have faced this type of problem  while opening any existing project . Sometimes we toggled any file in visual studio but after closing the application we unable to see the toggled file.  Sometimes by rebuild the solution  the issue is get resolved .  So this problem/ issue is caused due to various reason but among those reason one of them is worked for me . Click on image to view it properly.  Here is my solutions. It worked for me . Please follow my steps. Step 1:    Please go to the physical folders/files of your solution . Just right click of the solution and from the options choose "Open Folder is File Explorer". Please check the attached Image. Step 2:     Then you will see the files like this. Then please check the if the "Hide Items" checkbox is checked or not . If not checked please check that one. Then you will   see .vs folder .       ...

Unable to load one or more breakpoints in Visual studio.

Image
Those who are working on Visual studio IDE they might have faced this type of error while opening any existing project . Sometimes by rebuild the solution or removing the break points the issue is get resolved .  So this problem/ issue is caused due to various reason but among those reason one of them is worked for me .  Here is my solutions. It worked for me . Please follow my steps. Step 1:    Please go to the physical folders/files of your solution . Just right click of the solution and from the options choose "Open Folder is File Explorer". Please check the attached Image. Please click on Image to view it properly Step 2:     Then you will see the files like this. Then please check the if the "Hide Items" checkbox is checked or not . If not checked please check that one. Then you will   see .vs folder .                               Please click on Im...