【问题标题】:asp.net mvc3,razor,jquery mobile view Navigation problemasp.net mvc3,razor,jquery mobile view Navigation问题
【发布时间】:2011-03-02 13:18:37
【问题描述】:

我从一个移动页面导航到另一个页面,页面出现但页面上的控件

不会出现, 我正在使用带有剃须刀的 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 页面(和 master 一样)

<!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。

【问题讨论】:

  • 如果Request.Browser.IsMobileDevice 为假怎么办?您是否还有每个路由的视图,ListListM 位于与关联控制器链接的视图目录中或共享目录中?

标签: jquery asp.net-mvc mobile razor


【解决方案1】:

应该这样

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");
}

?

【讨论】:

    猜你喜欢
    • 2012-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多