• About Us
  • Blog
  • Basket
  • Account
  • Sign In
  •  

Blog

Published on Monday, July 11, 2011

How To Add a "Visit Mobile Web Site" Link To Your Web Site

Forward thinking web sites will have at least 2 different versions of their content. 1 for mobile browsers, and the other for the big screen desktop and laptop devices. 51Degrees.mobi does an excellent job of detecting the device type and redirecting the device to the correct content. To provide users with choice and enable them to switch between the different versions.

The following self contained user control can be added to any ASP web page to provide an optional link in the top left hand corner of the web page to enable users viewing the desktop big screen web page to switch to the mobile site. Importantly the link will only appear when the page is being viewed on a mobile handset or tablet.

<%@ Control Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.UserControl" %>
 
<script runat="server" language="C#">
 
    protected void Page_Load(object sender, EventArgs e)
    {
        Visible = Request.Browser.IsMobileDevice;
    }
     
</script>
 
<asp:Panel runat="server" ID="PanelMobileSite" BackColor="Silver" BorderColor="DarkGray" BorderStyle="Solid" BorderWidth="1px" Style="position: absolute; top: 0px; left 0px; line-height: 2em;">
    <asp:HyperLink runat="server" ID="HyperLinkMobileSite" NavigateUrl="http://m.51degrees.mobi" Text="Mobile Site" style="padding-left: 1em; padding-right: 1em; vertical-align: middle;" />
</asp:Panel>

ASCX User Control

Add the above code to an ASP user control, and then add the user control to your master pages, or ASPX web pages. The link will only appear when the page is accessed via a mobile device and provides an elegant method of enabling users to switch between content types.

Happy mobile web development.

Comments (0)

Author: Products Team

Categories: Development

Tags: Mobile

James Rosewell
>

Products Team

Other posts by Products Team
Contact author

Name:
Email:
Subject:
Message:
x

Tags

.NET 4G 51Degrees 5G Acer Adform Adtech Advertising Afilias Alcatel Amazon AMP Analysis Analytics Android Apache API Apple Asian Market ASP.NET Asus Blackberry Browser C C# Centro Chrome Cloud CMS CPU CSS3 Data Data Blog Data File Daydream Design Detection Developers Device Device Data Device Detection Device Intelligence Device Models Device property DeviceAtlas Disney dmexco DotNetNuke Download ebay Ericsson Event Facebook Firefox Foundation Framework Galaxy git repositories Google Google Analytics Google Daydream GPU GSMA Guess HAProxy Hash Trie HTC HTML5 HTTP HTTP Headers Huawei Infinix Ingeniux Internet usage iOS iOS 13 ipad iPadOS iPhone iPhone 11 Java Javascript Kentico LG Liferay LTE m.dot Memory Memory leak Meta Data Microsoft Mobile Mobile Analysis Mobile Analytics Mobile Devices Mobile Marketing Mixer Motorola Mozilla MWC MWC 2017 MWC16 Native Apps NET New Release News Nexus NFC NGINX Nokia OnePlus 5 Opera Operating System Oppo Optimisation OS Patent Performance PHP Press Release Price Band programmatic Publishers Python Redirection Research Responsive Images Responsive web design RESS Review RTB RWD Safari Samsung Scala ScientiaMobile SEO Server Server-side optimisation Seznam.cz Sitecore Smart TV Smartphone Smartwatches Sony Swedish Beers Tablet Tencent Testing Tips Tutorial Umbraco Update User Agent User-Agent Valgrind Varnish Varnish Cache Video Vodafone VoLTE Web Web Apps Web content management Webtrekk White Paper Widgets WiFi Windows WURFL Xiaomi Xperia ZTE