单个ASP.NET网站,具有针对PC和移动设备的不同设计 [英] A Single ASP.NET Website with different designs for pc and mobile

查看:61
本文介绍了单个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.

推荐答案

,您将需要捕获正在使用的设备的分辨率,并根据此分辨率来定义css文件.这样,当用户调用您网站的网址时,它首先必须检查设备的类型,然后必须根据您选择的CSS设计填充页面.
you would be required to capture the resolutions of the devices you are using and based on that you would be required to define the css files. so that when a user calls the url of your website it first has to check for the type of the device and then has to populate the page as per your choosen css''s designs..


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和移动设备的不同设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆