2011-03-02 74 views
0

我从一个移动页面导航到另一个,出现的页面,但不会出现在页面上的控件asp.net MVC3,剃须刀,jQuery Mobile的视图导航问题

, 我使用jQuery Mobile的和MVC 3用剃刀 这里是我的代码

主导航链接控制器的行动。

public ActionResult List() 
{ 
    if (Request.Browser.IsMobileDevice) 
    { 
     return View("List"); 
    } 
    else 
     return View("ListM"); 
} 

信息查看链接,将导航文件控制器

@{ 
    Page.Title = "ListM"; 
    Layout = "~/Views/Shared/_LayoutMob.cshtml"; 
} 
<div> 
    <ul data-role="listview" >  
     <li> 
      @Html.ActionLink("FileLink", "List", "File") 
     </li> 
    </ul> 
</div> 

这是_LayoutMob.cshtml页(就像主)

<!DOCTYPE html> 
@using DomainModel.Extentions; 
<html lang="en"> 
    <head> 
    <meta charset="utf-8" /> 
    <title>@ViewBag.Title</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" /> 
    <script src="http://code.jquery.com/jquery-1.5.min.js"></script>  
    <script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script> 
    <style type="text/css"> 
    body { background: #dddddd;} 
    .gmap { height: 330px; width: 100%; margin: 0px; padding: 0px } 
    </style> 

    </head> 
    <body data-role="page" data-theme="e"> 
     @RenderBody() 
    </body> 
</html> 

这是控制器(即链接导航应该在哪里)

public ActionResult List() 
{ 
    if (Request.Browser.IsMobileDevice) 
    { 
     return View("ListM"); 
    } 
} 

我使用的浏览器是Mozilla Firefox,IE8和iBB Demo2。

+0

如果Request.Browser.IsMobileDevice为false会发生什么?您是否也有查看每个路径的列表,List或ListM是位于与相关控制器链接的View目录还是共享目录? – 2011-03-02 13:51:06

回答

2

应此

public ActionResult List() 
{ 
    if (Request.Browser.IsMobileDevice) 
    { 
     return View("List"); 
    } 
    else 
     return View("ListM"); 
} 

是这样

public ActionResult List() 
{ 
    if (Request.Browser.IsMobileDevice) 
    { 
     return View("ListM"); 
    } 
    else 
     return View("List"); 
}