本文介绍了单个ASP.NET网站,具有针对PC和移动设备的不同设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,我需要设计一个ASP.NET(使用C#)网站,该网站可以在计算机和手机上使用.但是两种环境的设计应该有所不同.是否可以使用单个aspx页面来实现此目的.请尽快答复.

Hi friends, I need to design an ASP.NET(using C#) Website which can be used on computers as well as mobile phones. But the design should be different for the two environments. Is it possible to achieve this using a single aspx page. Please reply asap.

推荐答案


its better you develop a mobile web page for mobile devices .

you can detect a mobile device using following code in the page load :

<pre lang="c#">
    string strUserAgent = Request.UserAgent.ToString().ToLower();
    if (strUserAgent != null)
    {
    if (Request.Browser.IsMobileDevice == true || strUserAgent.Contains("iphone") ||
    strUserAgent.Contains("blackberry") || strUserAgent.Contains("mobile") ||
    strUserAgent.Contains("windows ce") || strUserAgent.Contains("opera mini") ||
    strUserAgent.Contains("palm"))
    {
    Response.Redirect("DefaultMobile.aspx");
    }
    }


这篇关于单个ASP.NET网站,具有针对PC和移动设备的不同设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 09:07