Posts

Donate

How To Send Or Upload A Form With Multiple Files Using HttpPostedFileBase Array, jQuery And Ajax In ASP.NET MVC

Image
Good evening, This blog post demonstrates on how to upload or send a form with multiple files using HttpPostedFileBase class which is a property of a model class using jQuery and ajax in ASP.NET MVC. Given a sample model, I have declared a HttpPostedFileBase array property which is responsible for handling multiple files. public class clsWeeklyStatusReports { public Guid ID { get ; set ; } public string DomainName { get ; set ; } public string EmployeeName { get ; set ; } public DateTime SubmissionDate { get ; set ; } public string SubmissionDateDisplay { get { return SubmissionDate.ToString( "MM/dd/yyyy" ); } } public string MimeType { get ; set ; } public string FileName { get ; set ; } public HttpPostedFileBase[] Files { get ; set ; } public clsWeeklyStatusReportsGM() { ID = Guid.Empty; DomainName = string .Empty; EmployeeName = string .Empty; MimeType = string .Empty; FileName = string .Empty

Set Focus Or Auto Focus Input Control Using Inserted And Directive Not Working In Vue.js 3

Hello, Given the input element with an autofocus directive that on page load, this control get's focused right away. <input v-autofocus :class= "{ 'error' : empname.length > 22 }" /> The code to automatically focus the control is shown below using the inserted() method. directives:{ autofocus: { inserted(el){ el.focus(); } } } For some reasons the code above does not work in Vue.js 3x. After reading the docs, the solution that work was to use mounted() function instead of inserted() method if you're using Vue.js 3x. directives:{ autofocus: { mounted(el){ el.focus(); } } } Cheers!

How To Show Or Hide node_modules Folder In Visual Studio Code Editor

Image
Good evening! After adding the node modules using 'npm i' command in a Quasar or Vue.js project, I needed to show that folder in Visual Studio Code project explorer window since it's part of the project. Some of the solutions provided was to add some json configuration in settings.json which did not work. The solution that worked for me was to alter changes in Visual Studio Code Preferences itself. To proceed, go to File -> Preferences -> Text Editor -> Files and scroll down to locate the Exclude pane. Hover to the node_modules value and click the 'Remove Exclude Item' button. After that, the node_modules folder appears in the project explorer window. Cheers!

Notepad++ Plugin GetText Method Not Getting Entire String In C#

Image
Good evening, We have this Notepad++ Plugin project that will read and parse an html document converted from a MS Word file and then change the html string into an Adobe In Design format. The issue is that the html document has over 20,000 plus lines even reaching 40,000 lines or more. The code below will get all the text from an active Notepad++ window but fails if the string content is huge. public unsafe string GetText( int length) { byte [] textBuffer = new byte [10000]; fixed ( byte * textPtr = textBuffer) { Win32.SendMessage(scintilla, SciMsg.SCI_GETTEXT, (IntPtr)length, (IntPtr)textPtr); return Encoding.UTF8.GetString(textBuffer).TrimEnd( '\0' ); } } After doing some debugging and troubleshooting, I found a solution that is to replace the size of the textBuffer variable from a static value 10000 to the actual length passed into the function parameter. public unsafe string GetText( int length) { byte [] textBuffer = new byte [length]; fix

Creating Your First Notepad++ Plugin Using Visual Studio 2019 And C#

Image
Hello, In this blog post, I'll demonstrate on how to develop a Notepad++ Plugin (64 Bit) using Visual Studio 2019 and C# assuming that you have installed a 64 Bit version of the latest Notepad++ Editor. This tutorial is based from kblisted Notepad++ Plugin Package in GitHub . The plugin's architecture can communicate with the Notepad++ or the underlying Scintilla engine using NotepadPlusPlusGateway and ScintillaGateWay and Win32 API. To start with, download the Notepad++ Plugin Pack from the GitHub page and copy the zip file to the Project Templates folder of your Visual Studio 2019 IDE. In my laptop, the path is "C:\Users\my_username\Documents\Visual Studio 2019\Templates\ProjectTemplates\Visual C#" . Open your Visual Studio 2019 IDE and create a project using the Notepad++ Plugin template. Change the Platform Target to x64. (Our OS is Windows 10 64 bit) Create a function called SetFirstCharAllWordsCap inside Main.cs that get's the entire string content

Activate Or Show Windows Forms Missing Controls Including BindingNavigator In .NET 5 or .NET Core Winforms Application

Image
Gents Good Day! There was a question on forums on why the BindingNavigator control was either missing or grayed out in Visual Studio Toolbox of which the project's target framework is .NET 5. I decided to create a C# Windows Forms application using Visual Studio 2019 that targets the .NET 5 framework and infact, the BindingNavigator control is missing. After searching the net, I found an interesting link in StackOverflow Activate missing Winforms controls in .Net Core 3.1 which is applicable to .NET Core 3.1. I applied the steps stated in the post's answer to the Windows Forms project that I created and it works. Below are the steps to do that. 1. Comment Application.SetHighDpiMode(HighDpiMode.SystemAware); code in Program.cs file. static void Main() { //Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault( false ); Application.Run( new Form1()); }

SQLBulkCopy Error - The given value of type String from the data source cannot be converted to type nvarchar of the specified target column. String or binary data would be truncated.

Image
Good day! Normally, in a situation where you want to inject thousands of rows to the database using C# and SQL Server, the optimal solution would be using built-in SQLBulkCopy() function. However, you may encounter the error message "The given value of type String from the data source cannot be converted to type nvarchar of the specified target column. String or binary data would be truncated." The code below works but in some instance may throw that kind of exception. private bool SQLBulkCopy<T>( string SqlConn, List<T> inList, string tableName, ref string errMsg, int optBatchSize = 5000, bool optTableLock = true ) { SqlBulkCopyOptions lockType; SqlTransaction transaction; if (optTableLock) lockType = SqlBulkCopyOptions.TableLock; else lockType = SqlBulkCopyOptions.Default; try { using ( var connection = new SqlConnection(SqlConn)) { connection.Open(); transaction = connection.BeginTransaction(); using ( var bulkCopy

Async Fetch Not Working When Retrieving Data From JSONPlaceholder API In JavaScript And Vue.JS

Image
Hello, I was trying to retrieve data from a Free Fake API website called JSON Placheholder using the code below which using asynchronous behavior. However, this does'nt return data after all. async getDataAsync(){ try { let response = await fetch( 'http://jsonplaceholder.typicode.com/todos' ); console.log(response.data); this .todos = response.data; } catch (error) { console.log(error); } After doing some research, I came up with a solution and replace the code above using JavaScript Promise as a means to retrieve data from the Fake API website in an asynchronous manner. await fetch( 'http://jsonplaceholder.typicode.com/todos' ) .then(response => response.json() ) .then(data => { this .todos = data; }) . catch (error => { return Promise.reject(error); }); } Cheers!

Axios.Get HTTP Client Not Returning Data From API In Vue.js

Image
Good day! I was following a tutorial on how to create a simple tutorial on how to create a Todo List project that retrieves data from a dummy API website in Youtube using the Axios HTTP Client Library. However fetching the API data from jsonplaceholder.typicode.com using Axios get() method does'nt return any results and the browser just rendered the white screen of death. After reading through my code thoroughly, I noticed that I have misplaced the created event inside the methods property which is the culprit of the issue. export default { name: 'home' , components: { Todos, Header, AddTodo }, data(){ return { todos:[], } }, methods:{ deleteTodo(id){ console.log(id); axios. delete (`https: //jsonplaceholder.typicode.com/todos/${id}`) .then(res => { this .todos = this .todos.filter(todo => todo.id !== id) return res }) . catch (error => {

Getting Started With Bootstrap-Table In An ASP.NET Core MVC 5 Web Application With Entity Framework Core And SQL Server

Image
Hello, In this tutorial, I will demonstrate on how to integrate Bootstrap-Table created by Wenzhixin in an ASP.NET Core MVC 5 with Entity Framework Core and SQL Server. For this post, I'll be using Microsoft's free database called ContosoRetailDW. Most of the ASP.NET MVC 5 web project in our company use this widget for showing records to clients because this has tons of features like exporting, paging, searching, sorting by column names and a whole lot more and this awesome widget has been constantly improved by the product owner and some dedicated developers. Project Setup 1. Lets start by creating an ASP.NET Core MVC application targeting the latest framework which is .NET 5 using Visual Studio 2019. 2. Add these NuGet packages for Entity Framework Core and ASP.NET Core MVC Newtonsoft.Json 3. Next is to reverse engineer the ContosoRetailDW so that we can use it's tables. The bootstrap-table widget will load records from DimPromotions table. Scaffold-DbContext "

Donate