Redirecting with Frames in ASP.NET Web Forms

In one of the applications that I work on, we have a frameset layout consisting one one horizontally narrow frame at the top of the page (composed of the header/menu), and one main frame in the remaining lower part of the page (composed of the rest of the content).

Ignoring the fact that I’m well aware that using frames is not a good approach in this day and age, there are some things that take time to move away from in an established application such as the one I work on.

In the mean time, I have been working on a “welcome screen” of sorts, where the user is given some stats about their account and those stats are occasionally linked to redirect them to the appropriate part of the application if they wanted to look more into the numbers.

I came across a problem when I attempted to redirect the user. In the header frame, we have a drop-down list made up of different sections of the application that users can navigate to. When the user clicks on a link from the welcome screen, they should be taken to the appropriate related screen in a different section. Thus, we would expect that the drop-down list in the header would automatically update to reflect the change.

This did not work in Chrome. However, it worked fine in Firefox and Internet Explorer. Yet another “feature” of Chrome. Go figure.

Get to the point

Yes, right. So in ASP.NET there are two controls for links. Either you use a LinkButton (with a PostBackURL attribute) or a Hyperlink (with a NavigateURL attribute), depending on if you need an event or not. I used one of those controls with the attribute instead of an event to avoid unnecessary calls to the server-side, but alas, that was the cause of the problem.

I had to switch the Hyperlinks to LinkButton, and then create an event that fires on click to do a Response.Redirect instead. This worked handsomely on all of the major browsers, and the drop-down list now updates appropriately.

I didn’t look more into it so I’m not quite sure about the technical details about why Chrome was not behaving like the other browsers, but nonetheless, I hope this tidbit of advice helps someone out there.


Clipboard Conflicts in Windows 7

I was recently made aware of a problem that has been plaguing my colleague for a few days, where when he would copy and paste rich-text content, or dynamic content such as formulas in Excel spreadsheets, the paste action would result in a plain-text version of the content to be pasted.

Let’s give an example

In Excel, you can copy formulas from one cell to another. This is normally evidenced by the “dotted line” outline you see when you copy a cell. However, in this scenario we were not seeing the dotted line, nor was the formula copied over to the other cell meaning only the actual text value of the cell was copied.

Another example would be to go to your browser and copy some text from a website that had changes in font (size, weight, etc). Upon pasting into Word, you can expect that all of the formatting will come along with it. However, in this scenario we were seeing only the text, stripped of formatting, being pasted.

Here’s the kicker

The problem would only appear when Internet Explorer (tested with v. 8 or 9) or Firefox (v. 11) was running.

If neither of those browsers were running, everything was working fine.

Let’s cut to the chase

After much debugging and troubleshooting, we found that there was an add-on enabled in both IE and Firefox (but not Chrome, which was not exhibiting this issue) which was the Skype Click-to-Call add-on.

For those of you unfamiliar with this add-on, it simply detects instances of potential phone numbers displayed in the HTML source and replaces them on-the-fly with clickable shortcuts to call the number using Skype.

Upon disabling the Skype add-on in both browsers, the problem disappeared and the clipboard was completely usable once again. It seems like the add-on was somehow hijacking the clipboard in some odd way.

The real interesting bit was that even if the content was copied to the clipboard without the browser running and pasted successfully with formatting, upon launching the browser and trying to paste the content again (without re-copying), the formatting would be stripped again.

TL;DR (Too Long; Didn’t Read) Version

If you are having problems with your clipboard behaving awkwardly around rich-text or dynamic content, first make sure the problem doesn’t persist even if no other programs are open, and then try disabling the Skype (or any unnecessary) add-ons in your open browsers.