Results 1 to 4 of 4

Thread: Invoke mobile skin on desktop

  1. #1
    Join Date
    Oct 2009
    Posts
    122

    Default Invoke mobile skin on desktop

    Is there a way to invoke the mobile skin on my desktop for testing purposes?

  2. #2
    Join Date
    Mar 2007
    Location
    Ashland, OR
    Posts
    2,390

    Default

    You would have to change the browser's user agent to make the site think you were on a mobile device. Safari has an option for this built in, and Firefox has some addons that make it easy.

  3. #3
    Join Date
    Jul 2008
    Location
    Silver Spring, MD
    Posts
    23

    Default

    I know this is an old thread - but here is how I did it.

    In web\App_Code\SkinBase.cs, in the function GetTemplateName, right below
    Code:
    m_ismobile = HttpContext.Current.Request.Browser.IsMobileDevice || CheckUserAgentForMobile;
    , I added the following:
    Code:
    m_ismobile = IsMobileOverride(m_ismobile);
    .

    The function IsMobileOverride is the following:
    Code:
    public static bool IsMobileOverride(bool OriginalValue)
            {
                //Check for Query String
                if (CommonLogic.QueryStringBool("ShowMobile"))
                {
                    HttpContext.Current.Response.Cookies["ASPDNSF.IsMobile"].Value = "1";
                    HttpContext.Current.Response.Cookies["ASPDNSF.IsMobile"].Expires = DateTime.Now.AddDays(30);
                    return true;
                }
                //Check for Query String
                if (CommonLogic.QueryStringBool("LeaveMobile"))
                {
                    HttpContext.Current.Response.Cookies["ASPDNSF.IsMobile"].Value = "0";
                    HttpContext.Current.Response.Cookies["ASPDNSF.IsMobile"].Expires = DateTime.Now.AddDays(30);
                    return false;
                }
    
                //Check for cookie
                string cookieIsMobile = CommonLogic.CookieCanBeDangerousContent("ASPDNSF.IsMobile", false);
                if (cookieIsMobile.Length > 0) // Override is set
                {
                    return (cookieIsMobile == "1");
                }
    
                return OriginalValue;
            }
    I then use ?showmobile=1 and ?leavemobile=1 to switch to and from the mobile skin.

  4. #4
    Join Date
    Jan 2006
    Posts
    34

    Default

    Great tip, thanks!
    EMM - Enhanced Email Manager

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •