Posts

Donate

Parse And Replace Element Attribute Value Of Script Template Using jQuery

Good afternoon fellow programmers! I recently have a task to load a Script template that contains HTML markup to a page dynamically. But before loading the template, I need to change the attribute values of certain elements such as id and name. However, reading the template object made it difficult for me to convert it to an HTML object so I can traverse and manipulate the DOM. After doing research and some experiments, I found the solution presented below on how to read the value of a Script template and be able to use jQuery methods to traverse and update the DOM elements. Sample Script Template To Load In A Page <script type= "text/html" id= "templateGroup" > <div name= 'divChildSkill_' class= "col-md-12" id= "divChildSkill_" > <div class= "col-md-12" > <div class= "col-md-6" > <div class= "col-md-4" > <label id= "anchorLabel" >...

XmlDataProvider With TwoWay Binding In WPF

Hello, Here's a simple example of two-way binding in WPF using XMLDataProvider. This post is taken from John Papa's example in MSDN magazine years ago but with minor errors. The XMLDataProvider markup has color values and is declared inside Window.Resources node. <Window.Resources> <XmlDataProvider x:Key= "MoreColors" > <x:XData> <colors xmlns= '' > <color name= "pink" /> <color name= "white" /> <color name= "black" /> <color name= "cyan" /> <color name= "gray" /> <color name= "magenta" /> </colors> </x:XData> </XmlDataProvider> </Window.Resources> The Textbox control's Text Text property binding has been set to TwoWay so when you enter a color name it will be added as a ListBox Item. <Grid> <StackPanel> <TextBlock Width= "248" Height= "24...

Bootstrap Table Footer Data Footer Formatter Not Computing Correctly On Multiple Columns

Image
Good Afternoon! I recently faced a minor bug in Bootstrap Table by Wenzhixin using a single data-footer-formatter for four columns. I expected that this will compute the column values but the expected result shows that all columns total are zero. Bootstrap Table <table id= "tblBillingReport" class= "TableBorderCollapse table-striped " data-toggle= "table" data-search= "true" data-show-columns= "false" data-advanced-search= "false" data-id-table= "advancedTable" data-show-export= "true" data-toolbar= "#toolbar" data-click-to- select = "true" data-unique-id= "objectID" data-cookie= "true" data-show-footer= "true" data-height= "700" data-cookie-id-table= "tblBillingReportID" > <thead> <tr style= "background-color: #FFFFFF;" > <th dat...

Export SQL Server Varbinary Or Blob To Disk Using C#

Image
Good evening Gents! I was given a task to export 100+GB of files from an MSSQL DB of which these files are saved in a table using Varbinary/Blob column. I've made some spike applications using BCP and .NET CLR but to no avail all the spike applications don't work since I don't have full permission to the database. The only solution that work for me was using the OLE Automation Procedures. So in order to export files from Blob, I'll present the steps below using AdventureWorks2012 database. 1. Enable OLE Automation Procedures by running script below. Use AdventureWorks2012 Go EXEC sp_configure 'show advanced options' , 1; GO RECONFIGURE; GO sp_configure 'Ole Automation Procedures' , 1; GO RECONFIGURE; GO 2. Run the stored procedure script below. The script will return the LargePhoto of a specific product. USE AdventureWorks2012 GO IF OBJECT_ID( 'SP_AdventureWorks_Export_Blob' , 'P' ) IS NOT NULL DROP PROCEDURE S...

Search Text In Files Using Utility Software Agent Ransack

Image
Hello, Just sharing a utility software that's something useful for searching text(s) from a number of files called Agent Ransack . This has been useful to me lately since I've been working on data formatting/cleanup projects that involves number of files. The tool is free and available for download from this site Agent Ransack . Sample Usage

Bootstrap Table Add Table Footer For Total Amount

Image
To add a footer row to the Bootstrap Table by Wenzhixin, set the data-show-footer attribute of that table to true. <table id= "tblInvoiceReport" data-show-footer= "true" > Next is to set the data-footer-formatter of the Amount column using a JavaScript function. <th data-field= "Amount" data-searchable= "true" data-class= "tdDetails" data-footer-formatter= "TotalFormatter" >Amount</th> And here's the JavaScript function to compute the total amount. function TotalFormatter (items) { var totalPrice = 0; items.forEach( function (item) { totalPrice = parseFloat(totalPrice) + parseFloat(item.Amount.replace( '$' , '' ).replace( ',' , '' )); }); return '$' + parseFloat(totalPrice).toLocaleString( undefined , { minimumFractionDigits: 2, maximumFractionDigits: 2 }); }; Output

How To Perform Bulk Update Using SqlBulkCopy, C#.NET And SQL Server

Image
Good afternoon! Before I go into details, this post is solely based on the solution provided in this link Bulk Update In C# . The purpose of this tutorial is to provide step by step approach on how bulk update can be achieved using SqlBulkCopy, C#.NET And SQL Server. First is to create a simple table in your database that holds some fictitious records. USE [testdatabase] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Person]( [ID] [int] NOT NULL , [Name] [varchar](50) NULL , [Address] [varchar](50) NULL ) ON [ PRIMARY ] GO Database table with temp records Next is to create a console app that will perform the bulk update of records. The key to solving performance issues in updating records is to use a temporary table approach. class Program { static void Main( string [] args) { var listPerson = new List<Person> { new Person() {Id = 1001, Name = "James A." , Address = "US" }, new Person(...

Extend Primary Partition With Unallocated Disk Space In Windows 10 Using MiniTool Partition Wizard

Good evening team! While I was doing an inventory of my Dell laptop's disk space, I found out that it has an unallocated size of around 70 GB and my C:\ primary drive is running out of space. My goal is to extend the C:\ drive with the unallocated space so that I can install more softwares and similar applications. My journey started with the Disk Management to extend the primary drive. Unfortunately, the Extend Volume feature is disabled. I started looking for answers in forums and tried some recommended free partition software to solve my case. But still no luck. After several hours of research, I finally extended my primary drive using a partition tool called MiniTool Partition Wizard . The tutorial to add extend a primary partition using unallocated space is presented here How to Merge Unallocated Space in Windows 10 for a Large Partition . Look for Case 2: Add Unallocated Space to Partition Windows 10 for the specific steps. Cheers!

How To Remove Duplicate Items In A List<T> Using IEqualityComparer<T>

Image
Good evening. Here's a simple demo on how to remove duplicate items in a List object using IEqualityComparer given that the generic list's type is complex. First we setup a simple model Employee class with Age, Name and Address properties. class Employee { public int Age { get ; set ; } public string Name { get ; set ; } public string Address { get ; set ; } } Next is to create a comparer class that implements IEqualityComparer interface. class EmployeeComparer : IEqualityComparer<Employee> { public bool Equals(Employee emp1, Employee emp2) { if (Object.ReferenceEquals(emp1, emp2)) return true ; if (Object.ReferenceEquals(emp1, null ) || Object.ReferenceEquals(emp2, null )) return false ; return (emp1.Age == emp2.Age) && (emp1.Name == emp2.Name) && (emp1.Address == emp2.Address); } public int GetHashCode(Employee obj) { ...

Generate Insert Data Scripts Without Identity Column In SQL Server

I have been generating insert data scripts through SQL Server Management Studio on the fly. However if you don't want to include the ID which is an identity column,this feature is not defined in the IDE. The workaround for this is to insert the records without the ID column into a temporary table and generate insert data scripts using that temp table. Select PartNum, PartDescription, Model, Category, SaleQTY, Price Into tmptblParts From tblParts The query above will insert records from tblParts to temp table tmptblParts. The column ID is omitted. After you have executed that statement, then generate insert scripts using tmptblParts.

Donate