0

I have one view using media for iPad views, when user wants to see portrait or landscape, the rendered view is different, but everything is set up on the same file.

Let's say we have

 <div class="portrait">
        <%= Html.CheckBoxFor(m => m.IsSelected, new { @checked = "checked" }) %>
 </div>

and on the same file:

 <div class="landscape">
        <%= Html.CheckBoxFor(m => m.IsSelected, new { @checked = "checked" }) %>
 </div>

What is the easiest way to have same data on both ?

I know you can solve it using jQuery onChange method manually, but is there any out of the box method that I could call in .Net MVC like SynchronizeView() or attribute and all elements get the same value on changing.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Tito
  • 722
  • 4
  • 26
  • 55
  • No matter what you have to detect the change on the client and send some request to the server unless you load both views on the client and switch views with jquery as you said. Here is how I see it 1. Detect the change ( unfortunately with jquery) 2. Send ajax request to get the correct view. or 1. Load both view on first request 2. Use js to switch ( hide and show) between the view. – Dan Hunex Apr 15 '15 at 19:33

1 Answers1

0

The easiest way to have same data on both is to use media queries. I highly recommended to render one html and adjust look and feel through styles. you can use orientation media query:

@media screen and (orientation: portrait) { … }
@media screen and (orientation: landscape) { … }

more information about css orientation detection

If it will not work for you, please make sure that you really need totally different views for portrait and landscape. I am worry that it will decrease UX of your site, makes user confused, and for sure makes application maintenance harder

Community
  • 1
  • 1
Marcin
  • 773
  • 6
  • 17