ASP.NET FriendlyUrls ViewSwitcher and jQuery Mobile

Sometime ago, September of 2012, Scott Hanselman blogged about a cool new library written for ASP.NET WebForms called ASP.NET Friendly URLs. The ASP.NET Friendly URLs library makes it easy to enable extensionless URLs for file-based handlers (e.g. ASPX, ASHX) in ASP.NET applications.  The library itself is very cool. In a nutshell, you, with two lines of code, can have extensionless URLs in ASP.NET web forms and have different pages served up for mobile devices.  Scott Hanselman’s blog post covers all of the details on features and implementation. I wanted to show you a problem that I had with using the library, namely the ViewSwitcher control, with jQuery Mobile.

I followed the thorough instructions on Scott Hanselman’s blog post about how to enable or create the mobile version of the site. Essentially you have to create a <MasterPageName>.Mobile.Master and then a <PageName>.Mobile.aspx for each content page that you want a mobile version for.  So in my case I created a SiteMaster.Mobile.aspx, a Default.Mobile.aspx and a EventInfo.Mobile.aspx.  Now when anyone browses the default or EventInfo page of my site with a Mobile device that ASP.NET detects, it will show that page instead and keep the URL the same.  If you want to see it action, visit http://teched2013.techedevents.info from a desktop or mobile device.  The creators of the ASP.NET Friendly URL library also created a helpful little control called ViewSwitcher.  The ViewSwitcher control allows the end user of the site to switch between the “desktop” view of a page and the “mobile” view of the page.  To add it, all you have to do is register the control on the page, and place it where you want on the page.

Site.Master and Site.Mobile.Master

<%@ Register Src="~/ViewSwitcher.ascx" TagPrefix="friendlyUrls" TagName="ViewSwitcher" %>

<!-- Add this where you want the control displayed -->
<friendlyUrls:ViewSwitcher ID="ViewSwitcher1" runat="server" />

 

Once these two lines of markup are on your Master Page, the FriendlyUrls library will generate a block of HTML enabling the user to switch views, if the page has an alternate view.

This works great out of the box if you are not using jQuery Mobile and the reason for it is not the FriendlyUrls library but the way jQuery Mobile tries to load pages via Ajax. If you run your application “out of the box” while on a jQuery Mobile based view, and try to switch to Desktop view you will get redirected to http://domainname/__FriendlyUrls_SwitchView?ReturnUrl=/, or something similar. This is because the FriendlyUrl libraries changes the view using a cookie and the jQuery Mobile framework only attempts to load the changes for the page (not the entire page) so there is a little trouble.  No worries there is a quick fix. If you open up the ViewSwitcher.ascx control and add the following attribute to the anchor tag

data-ajax="false"

This tells jQuery Mobile to not load that page with Ajax and load the entire page.

Ideally when the library hits the ASP.NET open source stack (its on its way), I or someone else will contribute this to the control to implement this small fix.

Visual Studio 2012–Update Issues

Yesterday I decided to re-pave my personal development machine because it was acting crazy.  Since Visual Studio 2012 Update 2 came out on that day, it was a no brainer for me to install Visual Studio 2012 and then apply Visual Studio 2012 Update 2.  All of the installations when fine until I tried applying the Visual Studio 2012 Update 2.  It keep on failing, and I mean like 15 times.  I tried running under administrative user, with / without anti virus, I tried downloading the “offline” version1.   However, NOTHING worked.  I kept getting an error reporting that the package vc_runtimeMinimum_x64 was failing.  I tried downloading the lasted version of it from Microsoft downloads but that did not work. After reading a couple of threads on the Visual Studio Setup and Installation forums and trying a few things I eventually got it to install. It did complain about a few different items not available but I did not have those products installed.

So what fixed, you asked? Windows Update!  More so I believe it was KB2781514 that did the trick. So you need to make sure your computer is totally update to date with the latest updates for this to work.

1 Run from the command line vs2012.2.exe /layout to download all of the files at once.

2 Year Retrospective

At around 6:30am PST on 3/19/2013, I hung up the phone from my last INETA North America Board meeting in which I was the President. I actually did not hit me until Nancy said, “Hey Joe, this is your last call as President” towards the end of the call. I was both relieved and saddened at the same time. I was relieved primarily because not everything was my ultimate responsibility anymore. I was saddened because I believe I had just started to gain momentum in making INETA more relevant again.

FYI, I did not lose an election or get fired or choose not run; the INETA Bylaws state that no officer (President, Vice President, Treasurer, or Secretary) can hold the position for two consecutive terms. I will stay on the INETA North America Board as Vice President underneath a good friend of mine, Julie Yack, the next President of INETA North America.

Let’s go back in time to the Microsoft 2011 Global MVP Summit (February 2011), at which point I knew I won the election for President but the announcement was not public yet. I started out my pre-term talking to a lot of MVPs, speakers, former INETA Speaker Bureau speakers and former Board members asking them what they honestly thought about INETA, its benefits and programs. There were two common responses “INETA still exists” or “INETA is no longer relevant.” After thinking about this for a bit, I remember a lengthy conversation I had with a friend of mine, Todd Anglin, in which Todd told me what INETA has done poorly in the past and what had worked. I remember telling Todd that I would be known as the President that “put the final nail in the coffin” and shut down INETA, or I would be known as the President that turned INETA around and made it relevant to user groups and the community again. I believe I have accomplished the latter.

After the Microsoft Global Summit, we, as a board, met over the phone and in person to come up with a strategy to “make INETA relevant again.” We began to really promote our Community Speaker Program as well as our Component Code Challenge heavily. The Community Speaker Program continues to grow as we add more speakers and more events every month. INETA also started to participate more actively in conferences, like Microsoft TechEd North America, DevConnections and DevIntersections, by having booths and side events like the INETA Community Leadership Summits.

In 2012, INETA turned the big One Oh (10) and we had a nice birthday celebration, we posted a blog a day (almost) where we asked the community to submit posts about INETA and how it has affected them. My favorite post was the kick off one. I wonder why :). During that month, we also kicked off the INETA User Group Kits, which I thought were awesome.

After our birthday celebration month, we continued to heavily work on increasing our speakers and community events throughout the year and worked on improving the website. We also made a huge effort to change the way we handled and requested sponsorship. We decided to stop asking sponsors for money every time something came up and decided it was best to break up what we do into components and offer the typical and potential sponsors of INETA North America the ability to sponsor parts of INETA that make sense for them. For more on that, feel free to check out the sponsorship page.

Unfortunately, there is much more to do. We want to refresh the INETA website, improve the process flow for the Community Speakers program, and if possible, add some mobile clients to the mix.

So if INETA has touched you in some way or helped you, let me know (leave a comment here) and let other present or past Board members know. If you are willing to help in some way to make “INETA relevant again,” shoot me an email at joseph.guadagno (at) ineta.org.

And a HUGE thanks goes to the great team of individuals that serve on the Board of Directors for INETA. It would not be a success without your hard work and dedication.

Great Events in November 2012

There are three great events coming to Phoenix this month.
  1. Desert Code Camp on November 17th : http://nov2012.desertcodecamp.com
  2. Windows 8 UX Design on November 26th: http://blogs.msdn.com/b/palermo4/archive/2012/11/06/2012-nov-26-windows-8-ux-design.aspx
  3. Markus Egger presents on .NET and Windows 8 at the Microsoft Offices in Tempe from 1p-4:30p On November 26th. Registration: http://www.codemag.com/Training/Detail/fbcc732a-4d69-49f7-9313-b031ea80d9f3 *
  4. Following that event, is Carl Franklin and Richard Campbell and the .NET Rocks tour from 6:00pm to 10:00pm. Registration: http://www.microsoft.com/click/services/Redirect2.ashx?CR_CC=200141036&CR_EAC=300056117
You definitely need to attend these great training opportunities. 
 
* Dinner will provided in the middle of the Markus Egger presentation and the .NET Rocks tour.

Upcoming Events in Arizona

I was going through the AZ Groups calendar this week and noticed that we have a lot of events going on in Arizona in the next two related to Microsoft .NET Technologies.  Here are some of the notable ones.

Event Calendar
DateTitleCityMore info
5/5 Windows Phone Unleashed
XNA
Tempe, AZ More Info
5/12 Windows Phone Unleaded
Business Apps
Chandler, AZ More Info
5/24 Southeast Valley .NET User Group
Special Guest Speaker
Chandler, AZ More Info
5/25 Microsoft Dev Camps
Web
Tempe, AZ More Info
6/6 Phoenix Connected Systems User Group
Special Guest Speaker
Tempe, AZ More Info
6/8 Microsoft Dev Camps
Windows 8
Chandler, AZ More Info
6/9 Microsoft Node Boot Camp Chandler, AZ More Info
6/19 AZGroups Day of .NET
with Scott Guthrie and Scott Hanselman
Scottsdale, AZ More Info
6/26 Southeast Valley .NET User Group
Special Guest Speaker
Chandler, AZ More Info

A lot effort is put into organizing these events and getting these “big” name speakers and content to come to Arizona, so show your support by attending these awesome free events.

About the author

Joseph Guadagno Name: Joseph Guadagno
Occupation: Programmer, Vice President of INETA North America, President of SEVDNUG, Microsoft Visual C# MVP
Location: Chandler, AZ

Joseph Guadagno RSS Joseph Guadagno Twitter Joseph Guadagno Linked In

Advertisements

Microsoft Application development contest