Saturday

Jquery Magnifier: How to develop image magnifier using mvc

Introduction

Jquery Image Magnifier is widely used in our web/Mobile app to view product images in all angles. Jquery Image Magnifier is used often in eCommerce website where end use can view minutely product image before to place order online. Here, Jquery magnifier is using in ASP.Net MVC App.

Include Two Style sheets files

CSS files are very important to enable Jquery magnifier using MVC application (Need to add stylesheet (demo.css, jQuery.MagnifierRentgen.min.css)).


Include Three JS File to Client Side Magnifier Effect

Here adding three java script file reference (online Jquery reference (jquery-1.11.3.min.js) & other two offline (jQuery.MagnifierRentgen.min.js, demo.js))



Razor View (CSHTML Page)

Showing complete Razor view code
@{
    ViewBag.Title = "Magnifier";

    
    
}


    

JQuery Magnifier

_Layout Razor View (App Layout default settings)

Here showing Layout Master Razor view code

Image Magnifier Output View First

Image Magnifier using MVC

Image Magnifier Output View Second

Image Magnifier using MVC

Conclusion

Jquery Image Magnifier can trust and motivated to buy product online through eCommerce website (marketplace). In this article, I have explained all steps to how can we zoom in, zoom out the image to give a very close look of the product image. This is very brilliant feature (Jquery Magnifier) in our eCommerce website.

Download Example

Download

Relevant Reading

Thursday

JQuery: Show Hide div on radio button using Jquery

Introduction

Today, Explaining about how to show hide HTML Div on radio button click containing input box on radio button click. This particular requirement arise whenever we are asking questions or confirming something on that basis we have to show and hide html controls under div, I have explained here in with great deal.

Show Hide div on radio button using Jquery

Tuesday

Fix GDI: A generic error occurred in GDI in MVC Application

Introduction

Providing solution to very common issue "A generic error occurred in GDI+." while working with ASP.Net MVC C# application. In this application, I was writing code to save image in Png format. Sometimes, we don't have any exact idea about issue, then we can wastage our precious development time, to overcome this issue, I come up here with to resolve this issue.  

Monday

Fix Error: Could not load file or assembly 'Antlr3.Runtime (1)' or one of its dependencies

Introduction

Today, I am going to explain a MVC application error while our application is interrupted or closed properly. This might be arise a major issue in our build causes delay to deploy our MVC app.

Error Description

Could not load file or assembly 'Antlr3.Runtime (1)' or one of its dependencies

Reasons

This issue comes when our power failure and resulted into our application is not closed down properly.
Could not load file or assembly 'Antlr3.Runtime (1)' or one of its dependencies

Figure: Could not load file or assembly

Step 1

Press Windows + Run and then type %temp%

Step 2

Now delete all temporaries files located at your machine C:\Users\user1\AppData\Local\Temp,

Using with above 2 steps helped me to resolve issue Could not load file or assembly 'Antlr3.Runtime (1)' or one of its dependencies while working on MVC application.

Conclusion

I have explained MVC error Could not load file or assembly 'Antlr3.Runtime (1)' or one of its dependencies, how it comes, reasons behind it and provided all necessary steps to resolve issue Could not load file or assembly 'Antlr3.Runtime (1)' or one of its dependencies. Relevant MVC Fixes

Suggested Reading

Saturday

MVC Razor View: Unexpected if keyword after @ character in MVC Razor View

Introduction

I am going to explain a very popular error i.e Unexpected "if" keyword after "@" character while working with ASP.Net MVC Razor View, I am sharing all aspects of this error Unexpected "if" keyword after "@" character.

Error Detail:

Unexpected "if" keyword after "@" character.  Once inside code, you do not need to prefix constructs like "if" with "@".
When Error "Unexpected "if" keyword after "@" character" comes off
Working on MVC project and working on MVC Razor view, meanwhile a problem faced me whenever using foreach statement in MVC Razor View Engine. I was using nested statement to write some logic. I have been shared my both preview of code 1) Wrong statement and 2) corrected statement which is showing below.

Unexpected if keyword after character in MVC Razor View

Wrong Statement

@foreach (var item in Model)
{
    @if (item.isCorrect)
    {
           // do something
    }
}

Correct Statement

@foreach (var item in Model)
{
    if (item.isCorrect)
    {
           // do something
    }
}

Conclusion 

Explained above, how can we use nested loop in Razor view, in this article, fully explained how can we remove issue of nested loop Unexpected if keyword after @ character.

Suggested Reading

SQL Server: Top 10 Queries of SQL Server

Introduction

T-SQL most top queries demonstrating today in this article. T-SQL is most important while dealing with database. MS SQL Server has provided  numerous T-SQL queries to check database performance, data manipulation queries, data definitions queries, roles/security check, transaction level etc.

Database Table with Data

CREATE TABLE [dbo].[tblPersonalDetail](
 [TablePK] [int] IDENTITY(1,1) NOT NULL,
 [First_Name] [nvarchar](100) NULL,
 [Last_Name] [nvarchar](100) NULL,
 [EmailID] [nchar](100) NULL,
 [Address] [nvarchar](200) NULL,
 [CellNo] [int] NULL,
 CONSTRAINT [PK_tblPersonalDetail] PRIMARY KEY CLUSTERED 
(
 [TablePK] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, 
 ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[tblPersonalDetail] ON
INSERT [dbo].[tblPersonalDetail] ([TablePK], [First_Name], [Last_Name], [EmailID],[Address], [CellNo]) VALUES (1, N'David', N'Moore', N'david.moore@you.com', N'new lane drive USA', 456789456)
INSERT [dbo].[tblPersonalDetail] ([TablePK], [First_Name], [Last_Name], [EmailID],[Address], [CellNo]) VALUES (2, N'Marry', N'Champ', N'marrychamp@you.com', N'straight drive, Lane I', 15478945)
INSERT [dbo].[tblPersonalDetail] ([TablePK], [First_Name], [Last_Name], [EmailID],[Address], [CellNo]) VALUES (3, N'Allan', N'Lamb', N'allan@you.com', N'Main Lane, London', 12312313)
INSERT [dbo].[tblPersonalDetail] ([TablePK], [First_Name], [Last_Name], [EmailID], [Address], [CellNo]) VALUES (4, N'Arya', N'Bhatt', N'arya@abc.com', N'Nalanda University', 12313154)
SET IDENTITY_INSERT [dbo].[tblPersonalDetail] OFF

Table Data View

table data view

SQL Next Record: How to get next record in SQL Server Table

SELECT TOP 1 LEAD(PD.TablePK) OVER (ORDER BY PD.TablePK) NextValue from 
 [tblPersonalDetail] PD where PD.TablePK >=1 order by PD.TablePK asc;
SQL NEXT RECORD

SQL Previous Record: Go to Previous Record in Table using SQL Server

SELECT TOP 1 MAX(TablePK)Previous_Record FROM tblPersonalDetail WHERE TablePK < 3;
SQL Previous Record

SQL Server: How to check Total Rows, Spaced Used, Indexed and unused Size?

EXEC sp_spaceused @updateusage = N'TRUE';
GO
EXEC sp_spaceused N'dbo.tblPersonalDetail';
check sql space used

Highest Salary: How to get 3rd Highest Value using SQL Server

SELECT TOP 1 TablePK from (SELECT DISTINCT TOP 3 TablePK FROM tblPersonalDetail 
 order by TablePK desc) a order by TablePK

SQL Defined Tables: List all user defined tables using SQL Server


SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'
INFORMATION SCHEMA TABLES

SQL Columns: List all columns in our database using INFORMATION_SCHEMA

SELECT * FROM INFORMATION_SCHEMA.COLUMNS
INFORMATION SCHEMA COLUMNS

Other INFORMATION_SCHEMA.ViewName: Here are listing of other Information_Schema metadata which allows you to retrieve rows of specific database from Master database.

SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS
SELECT * FROM INFORMATION_SCHEMA.COLUMN_DOMAIN_USAGE
SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES
SELECT * FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
SELECT * FROM INFORMATION_SCHEMA.CONSTRAINT_TABLE_USAGE
SELECT * FROM INFORMATION_SCHEMA.DOMAIN_CONSTRAINTS
SELECT * FROM INFORMATION_SCHEMA.DOMAINS
SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
SELECT * FROM INFORMATION_SCHEMA.ROUTINE_COLUMNS
SELECT * FROM INFORMATION_SCHEMA.ROUTINES
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
SELECT * FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES
SELECT * FROM INFORMATION_SCHEMA.TABLES
SELECT * FROM INFORMATION_SCHEMA.VIEW_COLUMN_USAGE
SELECT * FROM INFORMATION_SCHEMA.VIEW_TABLE_USAGE
SELECT * FROM INFORMATION_SCHEMA.VIEWS

SQL Date Formats: To see the date formats for your culture using MS SQL Server

EXEC sp_helplanguage

EXEC sp_helplanguage

Fig: Date Formats

XML Showplan: This statement returns showplan in XML format by the plan handle.

USE master;
GO
exec sp_who;
GO
SELECT * FROM sys.dm_exec_requests
XML Showplan

                                     Fig: XML Showplan

Select Last SQL Records: In this query how we can select last records using Top Statement in T-SQL

SELECT Top 4 * FROM dbo.tblPersonalDetail Order By TablePK desc
Select Top Query

Conclusion

In this article, I have demonstrated T-SQL top 10 queries in SQL Server. Which shows data from Master database of the SQL Server and few queries manipulate of specific database. Whenever we are working on top db administrator then we need to fire administrator level queries to tune up our database.

Relevant Reading

Thursday

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

Introduction

I was working on MVC application using Entity Framework, meanwhile I was setting up my code then a new error comes off me "Store update, insert, or delete statement affected an unexpected number of rows". After my deep study, then came up a perfect solution to remove this issue permanently from my solution. I have explained all steps as given below.

Error Description

Store update, insert, or delete statement affected an unexpected number of rows (0).
Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.

Store update insert or delete statement affected an unexpected number of rows (0)
Fix Entity Framework Error
Steps to Remove Error [Store update, insert, or delete statement affected an unexpected]

Set update mode to add, it was earlier set to modified state using entity framework. If table primary key greater than zero then it will modified otherwise it will add a new record in database table.

Wrong Statement

I had written given below wrong statement to add a new fresh record into my database table record, it was wrongly added state to Modified.
_context.Entry(model).State = EntityState.Modified;

Corrected Statement

Now, I corrected this statement, I just checked that primary key contains a value means a record need to update otherwise primary key value 0 means my database table needed to add a new fresh record in to my database table record.

if (model.TablePK > 0)
{
   _context.Entry(model).State = EntityState.Modified;
}
else
{
   _context.Entry(model).State = EntityState.Add;
}

Conclusion

While we coding seriously in our app then suddenly can trap up in few unexpected issues i.e. Store update, insert, or delete statement affected an unexpected. I have provided complete to recover unexpected issue. Hope it will help to all who eventually got in this issue i.e. Store update, insert, or delete statement affected an unexpected.

Suggested Reading