How to check if all items are the same in a list C#

March 13, 2019 Leave a comment

Here is sample code to check if all the items are same in a list

if(list.Any(x=> x ! = list[0]))

If you want to check any specific property use following code

if(list.Any(x=> x.Name ! = list[0].name))

Hope this help!

Categories: Tips & Tricks

How to Collapse all #regions only(!) in C# (Visual Studio)

March 12, 2019 Leave a comment

Follow below step to Collapse all #regions

  • Go to Tools Menu of Visual Studio
  • Select Options
  • Select Text Editor
  • Select C#
  • Select Advanced Option
  • Checked Collapse #regions when collapsing to definitions

Now if you press ctrl + m + o it will collapse all #regions.

Categories: Tips & Tricks

Issue: Password field returned empty in edit mode

January 4, 2019 Leave a comment

This is as per design. Passwords are not filled to prevent accidental resubmits, and to prevent the page from containing unencrypted passwords.

Here is the solution

@Html.PasswordFor(model => model.Password,new{@Value=Model.Password})

@Html.PasswordFor(model => model.Password, new { placeholder = "********" })

This will put some 'visual' asterisks in the input box which will be disappeared when the user starts entering an actual value.

Hope this help!

Categories: Tips & Tricks

Load XML from URL giving an error (The remote server returned an error: (401) Unauthorized.)

November 1, 2018 Leave a comment

If you are getting a 401 Unauthorized error while reading an XML from URL, here is the solution you can try


Hope this help!

Categories: ASP.NET Tags: , ,

How to use Variable in MySQL Like Clause ?

October 24, 2018 Leave a comment

Here is an example to use SQL variable in the mysql select query like clause

SET @name = 'advancewebsoftware';

SELECT * from `user` WHERE name LIKE CONCAT('%', @name, '%');

Hope this help!


Categories: Sql Server Tags: , ,

Error :(System.Web.UI.HtmlControls.HtmlIframe) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlGenericControl) in VS2017

Reason for the above error is I have my project in .NET framework 3.5 and I update it to .NET framework 4.5,

Solution for the above error is:
We need to change the *.designer.cs file reference from:




Categories: ASP.NET

MySQL : The user specified as a definer (‘root’@’%’) does not exist

This error occurs when exporting views/triggers/procedures from one database or server to another as the user that created that object no longer exists.

So here are the solutions:

  • Change DEFINERCreate the missing user
  • Create the missing user

or simply run following query

grant all on *.* to ‘root’@’%’ identified by ‘password’ with grant option;

Hope it helps.

Categories: ASP.NET