Showing all posts tagged: 'JavaScript'

A 22-post collection

Setting up a Gulp task with Visual Studio Code

As a web developer, certain tools have become indispensable. I can't even imagine having to do any front-end work without [npm](https://www.npmjs.com/" target="_blank), [Grunt](http://gruntjs.com/" target="_blank) or [Gulp](http://gulpjs.com/" target="_blank). In fact, these tools are so great that the upcoming release of ASP.NET has thrown away proprietory package and task managers in favour of the widely adopted and established tools used by the community. And these tools are now first class citizens both in Visual Studio and Visual Studio Code. Classic .NET developers …[read more]


Add "copy-to-clipboard" functionality to your website

I'm currently working on releasing a nice front-end to [https://passwordutility.net](https://passwordutility.net" target="_blank). PasswordUtility.net is an OSS tool that allows users to check their passwords' strength. You can also generate strong passwords using the same tool. If you're ever stuck for a password, head over to the site and give it a go! There's also a funky API and free OSS library release as NuGet package so you don't have to re-invent the wheel. With the shameless plug out of the way, I'll get to the chase. How do you add a copy-to-clipboard …[read more]


Logging with AngularJs - extending the built-in logger

AngularJs has an impressive and robust logging mechanism through the $logService and $log injection. However, Angular logs everything to the console, which is neither a robust or scalable solution. Sometimes, you need to be able to intercept the exceptions and do something extra. This could be as simple as adding extra information or sending all logs to the server/database. Below I've included two different ways that you can achieve that. Option 1 The first one is pretty simple and allows you to hook into the $exceptionHandler and pass a logger in the form of an AngularJs factory. The factory …[read more]


Getting started with TypeScript and Sublime Text

UPDATED: This post has been rewritten around the official TypeScript plugin [Typescript](http://www.typescriptlang.org/" target="_blank) is awesome, period. TypeScript, in case you don't know, is a superset of JavaScript that allows you to use Object Oriented principles in order to write code that can be compiled to JavaScript. In effect, you can use optional static typing, modules, interfaces and classes to write your code and once the code is compiled, the end result is an idiomatic javascript code that resembles the code that you would directly javascript if you wanted to create classes etc without …[read more]


How to use JQuery dialog as Confirm dialog in ASP.NET

Another ASP.NET WebForms post. It seems I'm "stuck" with WebForms for now, so lets make the best out of it. Today's issue: how many times did you have to code some confirmation logic on your website to ensure that your users are (doubly/triply) sure about the action they are about to perform? A typical example is prompting the user to confirm that they are sure about deleting a record. In typical/boring javascript world, you would do something like this: HTML <asp:Button runat="server" ID="btnDelete" Text="Delete" …[read more]


Upload files in ASP.NET MVC with JavaScript and C#.

In an earlier [post](GHOST_URL/upload-files-to-the-server-using-javascript-and-mvc-webapi/" target="_blank), I described how to implement a file upload using [Ajax](http://api.jquery.com/jquery.ajax/" target="_blank) and [ASP.NET WebAPI](http://www.asp.net/web-api" target="_blank). This works great but it means that you need to have a WebAPI controller to manage the requests. If you already have a WebAPI in your solution then you can simply extend it to manage file uploads. However, there's no reason to add a WebAPI only for file uploads. Instead you can use an MVC controller …[read more]


Processing Payments and with Stripe, JavaScript and C# - PCI compliant

The source code and post have been updated to use the latest Stripe.NET API => v4.2 Online payments! We've all used them and some of us may have had the "fortune" implementing them on one website or another. [Stripe](http://stripe.com" target="_blank") is the not-so-new kid on the block, since it recently expanded in many countries, that makes this development task a breeze. If you are using .NET, then [Stripe.NET](https://github.com/jaymedavis/stripe.net" target="_blank) is an excellent library that hides away most of the …[read more]


How to Implement Cross Domain Requests (CORS) in WebAPI, old school

WebAPI is awesome. It allows .NET developers to quickly set up a public API for any data with minimal effort. WebAPI has been available for a while and with each iteration, it grows stronger and more versatile. However, there is no point in offering an API that no one can consume it. WebAPI works great straight out of the box for GET requests. However, once you start using it for POST, PUT or DELETE operations, then CORS kicks in and drops requests from hitting the server. CORS stops any cross domain requests so if your api is running at www. …[read more]