Multiple calls to page when using Asp.Net Gridview

I am stuck with some legacy code and I am trying to figure out why a certain page is called/loaded several times. It contains a gridview element. It turns out after some internet searching that there are several reasons why the page is loaded several times.

When the page is loaded the gridviews OnSelecting method is called twice. Once to populate the gridview, and once to count the elements in the gridview (ExecutingSelectCount).

Another reason the page is loaded several times in a row is if you add dynamic stylesheets in the code behind after you’ve bound the data to the gridview. This causes the page to load several times. Two times extra the be exact. This is seen when the OnSelecting method is called four times when the page loades.

Third reason is if you dynamically show/hide columns in the gridview. This causes some extra reloads, exactly as in the case of dynamic css above.

So, two calls to OnSelecting method is normal and according to spec. More calls might be because you are fiddling with the gridview after the databind call, causing it to reload. Try and move the logic to dynamically change the gridview earlier in the load of the page.

Blank page when loading Jenkins

Lately I’ve experienced that I can’t use Jenkins in Google Chrome. I get a blank page. Nothing seems to work. A team mate of mine said “You have to use Internet Explorer”.

Using Chrome Devtools i saw that I received a HTTP 413 when I went to the server. After some searching on the Internet i found this

So, I tried deleting all cookies coupled with the Jenkins server. That solved the problem. I can use Chrome and Jenkins now. And I know what to do when I encounter the same problem again…

Email notifications on Readynas Duo v2 using gmail and 2-step verification

I had some problems enabling email alerts on my Netgear Readynas Duo v2 (firmware 4.1.14) using Googles Gmail as email provider. Then I remembered that I use 2-factor verification. This is how I solved it:

Go to System -> Warnings -> Contacts to fill out your contact information. Add Gmail as email provider. Fill in your Google/Gmail login credentials, and use your email address as sender address. I guess you could use any string here, but just to be safe and not get caught by the anti spam filter I choose to use my email address.

Netgear Readynas Email notification settings
Netgear Readynas Email notification settings

Press Send Test Message. Voila, nothing happens. Why? You need to generate an app password when you use Gmail with 2-step verification. Go to to manage your app passwords.

Google Connected apps & sites
Google Connected apps & sites

Click on Connected Apps & Security, and then Manage Apps.

Google Connected apps & sites app passwords
Generating app password at Google Connected apps & sites

Click on Select App and choose Other (Custom Name). Give the new app a descriptive name and click Generate. Google will now generate an app password for you.

Google apps generated app password
Google apps generated app password

Copy the password and go back to your Readynas and paste the password in the password field. Press Send Test Message and then check your email. Voila! You have an email from your Readynas there.

Open multiple instances of Visual Studio

You learn something new every day. But this is something special.

I’ve been trying to start an extra instance of Visual Studio. Whatever I’ve tried it just puts focus on the current instance. So a quick stop at google led me to Stackoverflow and a brilliant solution. Here it goes:

Middle click on the icon in the taskbar. Voila!

So easy and so brilliant that I will probably never forget it.

Now I got so many instances of VS that I’ve to reboot my computer.

P.S. One could hold down shift while clicking on the icon in the taskbar, or right click on the icon in the taskbar and click on the program.

Detecting IE Compatability Mode

I need to detect if Internet Explorer is in Compatablity Mode. If it is in compatability mode we want to show a text to the user urging them to turn off compatability mode. Googling around I found quite a lot of suggestions on how to do it. There were also quite a lot of text telling me to use Feature Detection instead of Browser Detection. There were tons of information. I zoomed in on these solutions:

I soon realized that the solution that I where to provide wasn’t going to be future proof. And that is ok for now. We just need to fix the problem. Quick and dirty is ok. So I ended up using the following javascript, which works like a charm.

Once included in the project its usage is straight forward:

var browser = IeVersion();
//Check that browser is Internet Explorer
if (browser.IsIE)
   // Check if browser is in compatability mode
   if (browser.CompatabilityMode)
      document.getElementById('CompatibilityModeWarning').style.display = 'block';