2011-03-02 187 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"); 
}