Razor Pages ajax modals with validation

This tutorial will show you how to create ajax powered Bootstrap modals in Razor Pages. You’ll learn how to dynamically load partial content, how to send/save your form via ajax and how to validate it using Razor Pages as a backend technology. Final proof-of-concept source code is in this GitHub repository. As a side note, if you want to see how to the same thing in ASP.NET Core then go to my other tutorial: ASP.NET Core ajax modals with validation using Bootstrap. ...

June 9, 2019 · 15 min · Zbigniew

C# file status (readable, writeable, is file, is directory)

Every once in a while you have to work with files. This article will teach you how to check wheter or not file is readable or writeable. You’re also going to learn how to check if given file or directory exists. Quick intro to C# File, FileInfo, Directory and DirectoryInfo classes All four classes reside inside System.IO namespace. It’s important to notice the differences between those clasesses, especially in terms of not-Info and Info classes. ...

April 28, 2019 · 3 min · Zbigniew

Handling keyboard shortcuts in JavaScript

Keyboard shortcuts are not only for desktop applications. You can also create shortcuts for web applications, which can come in handly in your MPA or SPA apps. Read on to find out how to create keyboard shortcuts in JavaScript. The key events Inside web browsers we have 3 distinct events related to keyboard events. keyup – fired after you release a key keypress – fired once you press a key, which produces a character value like a letter or number, but not for special characters like CTRL keydown – fired after you press a key We can use these events to call desired function. You can attach events to chosen input fields. Since we want it to work (almost) like a desktop app, we’ll attach the event handler to document. Also, the event handler has one parameter which contains all event properties. ...

March 31, 2019 · 4 min · Zbigniew

Strings in C# - concatenating (joining) and splitting

As a programmer you’ll always have to deal with the strings. In this article you’ll learn the most basic string operations: concatenating/joining and splitting. Concatenating/joining strings Concatenation means that you append a one string at the end of another string. This happens directly or indirectly, but you should know that there are a few ways you can join strings in C#. The + operator The simplest method of joining strings together is the + operator. It’s as easy as putting + in between strings: ...

February 24, 2019 · 5 min · Zbigniew

ASP.NET CORE OWASP TOP 10 - Cross-Site Scripting (XSS)

Cross-site scripting (known also as XSS) is a type of attack aimed at web application users. Attacker injects client-side code (typically a JavaScript) into vulnerable web application in such a way that the script is run on on users browsers visiting vulnerable page. Imagine that you’ve build an web application allowing your users to send private messages to each other. One of the users finds out that you do not encode messages, so it is possible to send pure HTML or JavaScript code to other person. The user decides to send this message to his buddy: ...

January 27, 2019 · 4 min · Zbigniew