Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MVC3中相同操作的不同视图_C#_Asp.net Mvc_Mobile Website - Fatal编程技术网

C# MVC3中相同操作的不同视图

C# MVC3中相同操作的不同视图,c#,asp.net-mvc,mobile-website,C#,Asp.net Mvc,Mobile Website,我正在使用ASP.NET MVC3开发一个移动web。我需要根据不同大小设备上可用的不同屏幕分辨率来更改视图,使其最适合 举个例子, 这里我有一个行动电话销售历史记录。并查看call SalesHistory.cshtml 我决定创建4个视图(与本机应用程序开发中的视图相同),根据不同设备上可用的不同屏幕分辨率排列内容。 所以我需要 SalesHistory_xhdpi.cshtml SalesHistory_hdpi.cshtml SalesHistory_mdpi.cshtml SalesH

我正在使用ASP.NET MVC3开发一个移动web。我需要根据不同大小设备上可用的不同屏幕分辨率来更改视图,使其最适合

举个例子,

这里我有一个行动电话销售历史记录。并查看call SalesHistory.cshtml 我决定创建4个视图(与本机应用程序开发中的视图相同),根据不同设备上可用的不同屏幕分辨率排列内容。 所以我需要

SalesHistory_xhdpi.cshtml
SalesHistory_hdpi.cshtml
SalesHistory_mdpi.cshtml
SalesHistory_ldpi.cshtml
现在,我需要在调用方法之后,在文件系统中查找cshtml文件之前,将post fix(_xhdpi/_hdpi/_mdpi或ldpi)添加到viewfile名称中。这里我有逻辑来决定后pix


如何更改视图文件名?

如果无法使用简单的CSS查询进行更改,并且您必须拥有不同的视图文件,则可以使用以下代码进行更改:

DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("ldpi") {//condition to detect resolution)});

请查看本网站,了解一个很好的开始,特别是关于按移动类型提供单独视图的部分:

MVC4将允许它以本机方式运行,请勾选:是。。但没有机会搬到mvc4。谢谢