locked
Hello. Trying to get jQuery.Mobile.MVC working with mvc5 RRS feed

  • Question

  • User1451609391 posted

    Hello. I have made a website with mvc5 and am now trying to make a cell phone version. I followed these instructions.

    https://www.c-sharpcorner.com/UploadFile/4b0136/introducing-mobile-site-in-mvc-5-and-jquery-mobile/

    I do have a developer version of firefox and the mobile view switcher is on mobile. When i try to run the _Layout.Mobile.cshtml  in my browser it just runs _Layout.cshtml so the view switcher is not taking effect.

    I installed the nuget package on the nuget package manager Install-Package jQuery.Mobile.MVC

    It installed these things on my site

    • A ViewSwitcher partial view and supporting Controller
    • Basic _Layout.Mobile.cshtml and supporting CSS
    • Newly added BundleMobileConfig.cs

    I added

        BundleMobileConfig.RegisterBundles(BundleTable.Bundles); to application_start in Global.asax

    The only way that i could get the _Layout.Mobile.cshtml page to run is by changing the filepath in viewstart.cshtml to the mobile version of the _Layout.cshtml

    @{
        Layout = "~/Views/Shared/_Layout.cshtml";
    }

    Please help thanks.

    Friday, September 25, 2020 2:45 PM

All replies

  • User-474980206 posted

    I believe you are on the wrong track. jQuery mobile is no longer supported and a poor choice for a new project. MVC 5 switched to responsive bootstrap in its templates.

    you should just learn bootstrap, and make your site responsive.

    Friday, September 25, 2020 3:31 PM
  • User1451609391 posted

    Thanks a lot I will make the switch.

    Friday, September 25, 2020 5:27 PM
  • User1451609391 posted

    Hello. I have been thinking about this and reading about it. I read about bootstrap and it seems to use responsive styles. I have a totally different layout for my mobile app. Is there a way to make two seperate websites one that will load when its a mobile phone. I would like a view to recognize when the page is loaded on a phone and show a totally different layout. Either make a whole other website or use the same one and change the views content when the page is a phone or desktop. Is this possible thanks.

    Friday, September 25, 2020 6:29 PM
  • User475983607 posted

    Responsive website display is based on the screen size.  The screen size is used because it is difficult to distinguish a mobile browser from a desktop browser yet you still need the screen size.  Mobile devices vary in size.  

    Anyway, you can write code to detect the browser then return whatever layout page you like.  Just do a Google search...

    Friday, September 25, 2020 6:50 PM
  • User1451609391 posted

    Ah I like that. So I can write code to detect the size of the screen then in viewstart.cshtml I will load in the mobile layout. I like that solution. Thanks all for your help.

    Saturday, September 26, 2020 1:50 AM
  • User475983607 posted

    Ah I like that. So I can write code to detect the size of the screen then in viewstart.cshtml I will load in the mobile layout. I like that solution. Thanks all for your help.

    You totally missed the point,  The screen size cannot be found on the server.  Responsive frameworks like Bootstrap use the screen size on the client to determine the layout.  

    Saturday, September 26, 2020 10:59 AM
  • User1451609391 posted

    Yes thanks i figured it out i hide the content i do not want to show with bootstrap classes and show the content i want. thanks

    Saturday, September 26, 2020 12:14 PM
  • User1686398519 posted

    Hi johnboyman12, 

    Has your problem been solved? If the problem is not solved, can you explain the problem more clearly?

    Best Regards,

    YihuiSun

    Monday, September 28, 2020 7:52 AM