Posts

Donate

Check If Images Are Not Rendered Correctly To The Browser Using JavaScript

Hello, Here's a function to hide divs if it's children specifically images does not render correctly to the browser or an error has occured. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 function ImageDivHandler() { $( "div.gallery" ).each( function () { if ($( this ).children().length == 0) { $( this ).hide(); } else { var img = $( this ).find( ".image-responsive" ); if (img != null || img != undefined ) { imgSrc = $( this ).find( ".image-responsive" ).attr( "src" ); if (imgSrc == "" || imgSrc == null || imgSrc == "null" ) { $( this ).find( ".image-responsive" ).closest( "div.gallery" ).hide(); } else { $( this ).find( ".image-responsive" ).error( function () { $( this ).closest( "div.gallery" ).hide();

jQuery Intellisense Not Working In External Javascript File Using Visual Studio 2013

Image
Hello, In order for the jQuery intellisense to work in Visual Studio 2013, perform the following steps. 1. Proceed by clicking Tools -> Options -> Text Editor -> JavaScript -> Intellisense -> References. 2. Change Reference Group to Implicit (Web)   By default a reference has been added to _references.js. If not, add a new reference file under Scripts folder. 3. Open _references.js file using your Visual Studio IDE or any text editor software. 4. Add reference path to jquery files (.js, .min.js, and .intellisense.js). 5. Close Visual Studio and Open it again. (I was struggling for hours as to why performing steps 1 through 4 didn't work. This step fixed the issue) Reference: jQuery intellisense not working in VS 2012 Regards, :)

ASP.NET WebForms Change GridView Sort Link Color

Image
Here's how to change the color of GridView SortLink using CSS. ASPX Markup 1 2 3 4 5 6 7 8 9 10 11 12 <asp:GridView ID= "GridVwPagingSorting" runat= "server" AutoGenerateColumns= "False" Font-Names= "Verdana" AllowPaging= "True" AllowSorting= "True" PageSize= "5" Width= "75%" OnPageIndexChanging= "PageIndexChanging" BorderColor= "#CCCCCC" BorderStyle= "Solid" BorderWidth= "1px" OnSorting= "Sorting" > <AlternatingRowStyle BackColor= "#BFE4FF" /> <PagerStyle BorderColor= "#CCCCCC" BorderStyle= "Solid" BorderWidth= "1px" /> <HeaderStyle CssClass= "gridViewHeader" /> <RowStyle Height= "20px" Font-Size= "13px" BorderColor= "#CCCCCC" BorderStyle= "Solid" BorderWidth= "1px" /> <

Alphabetical Paging in ASP.NET MVC (C#)

Image
Here's the C# version of Alphabetic Paging in VB.NET Posts: 1. Alphabetical Paging in ASP.NET MVC 2. Alphabetical-Paging-in-ASP-NET-MVC Source Code Solution Structure HtmlHelpers.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Text; using System.Web.Mvc; namespace MVCAlphabeticPager.Helpers { public static class HtmlHelpers { public static HtmlString AlphabeticalPager( this HtmlHelper html, string selectedLetter, IEnumerable< string > firstLetters, Func< string , string > pageLink) { var sb = new StringBuilder(); var numbers = Enumerable.Range(0, 10).Select(i => i.ToString()); var alphabet = Enumerable.Range(65, 26).Select(i => (( char )i).ToString()).ToList(); alphabet.Insert(0, "All" ); alphabet.Insert(1, "0-9" ); var ul = new TagBuilder( "ul" );

Alphabetical Paging in ASP.NET MVC (VB.NET)

Image
   Here's a sample ASP.NET MVC 5 project using Alphabetical Paging concept of Mikesdotnetting. The revisions are made on the Model, User Interface, and the database used. I replaced Northwind db with Adventureworks. Solution Structure Sample Output The source code/files and instructions on how to create this project using Visual Studio 2013 are elaborated in VBForums code bank. Alphabetical Paging in ASP.NET MVC

Entity Framework Join Two Tables If The Foreign Key Is A Nullable Column

Image
Hello, When retrieving records by joining two tables wherein the foreign key of the referenced table is a nullable column, and you want to return all records from the primary table, with or without the matching rows in the right table, the query would be using left join rather than inner join. So in LINQ expression, rather than inner join, revise the query to left join as presented below. Show products with matching categories, disregarding other products without categories MVC View: Code: 1 2 3 4 5 6 7 8 9 10 11 model.Products .AddRange( ( from item in context.Products .Where(item => item.Name.Trim().StartsWith(selectedLetter)) join category in context.ProductSubcategories on item.ProductSubcategoryID equals category.ProductSubcategoryID select new ProductModel() { ProductName = item.Name, ProductID = item.ProductID, ProductNumber = item.ProductNumber, Color = ( string .IsNullOrEmpty(item.Color)) ? "NA" : item.Color, St

ASP.NET Web Forms Show Tooltip In Gridview Column

Here's how to show tooltip in an asp.net gridview column/cell on mouse hover. This option will set the Tooltip property of a particular gridview cell on RowDataBound event. C# Code: 1 2 3 4 5 6 7 8 protected void grdCustomers_RowDataBound( object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string str = e.Row.Cells[1].Text; e.Row.Cells[1].ToolTip = str; } }

Entity Framework - Store update, insert, or delete statement affected an unexpected number of rows (0)

As I was creating a simple Create, Update, Delete (CRUD) application in ASP.NET MVC 5 and executing the controller on Edit, I encountered an error called "Store update, insert, or delete statement affected an unexpected number of rows (0)". After debugging and looking at the stack trace, I found out that the value of the primary key is zero. Department: "Education" Designation: "Dean" EmployeeName: "JE" EmployeeID: 0 Salary: 25500 The fix for this issue is to add a hidden field to the edit view referencing to the primary key which in this case is the EmployeeID. @Html.HiddenFor(model => model.EmployeeID) And now, the model passed to the context now has a value for the EmployeeID field. Department: "Education" Designation: "Dean" EmployeeName: "JE" EmployeeID: 2 Salary: 25500 Cheers! :)

How To Reset Cascading Dropdown Controls Using JavaScript And jQuery

Hi, Recently, I have encountered an issue on how to reset cascading dropdown controls in cross browsing mode (IE/Firefox/Chrome) using JavaScript and jQuery. After creating code spikes, I come up with a solution that works across major browsers. Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 $( ".reset-link" ).click( function () { ResetCascade($( this )); }); function ResetCascade(itemReset) { var formID = $(itemReset).closest( '.contact-form' ); if (formID != null ) { var firstDropDown = $(formID).find( '.cascading_group' ).find( '.firstDropDownDiv select' ); var secondDropDown = $(formID).find( '.cascading_group' ).find( '.secondDropDownDiv select' ); var thirdDropDown = $(formID).find( '.cascading_group' ).find( '.thirdDropDownDiv select' ); if (firstDropDown != null ) { var valueId = $(firstD

The type or namespace name 'LineShape' does not exist in the namespace 'Microsoft.VisualBasic.PowerPacks' (are you missing an assembly reference?)

Image
Good day! After migrating and then rebuilding the solution of a Windows Forms application from Windows XP machine to Windows 8, I encountered an error as stated on the title of this post. I suspect this has something to do with the old version from the XP machine not recognized on the new machine. The steps to fix this issue are provided below: 1. Download Microsoft Visual Basic Power Packs 3.0 here: Microsoft Visual Basic Power Packs 3.0 2. Remove the previous Microsoft Visual Basic Power Packs under References in your project 3. Add the MS Power Pack version 3.0 as reference to your project from the default installation folder located here: C:\Program Files (x86)\Microsoft Visual Basic 2005 Power Packs\3.0 4. Rebuild your project. Greg Esguerra:)

Donate