locked
repeatdirection horizontal change o vertical in mobile devices RRS feed

  • Question

  • User1407828493 posted

    I am using asp:DataList and I have set it to  RepeatDirection="Horizontal". It is giving me 4 raws one column in the web browser. That is fine and that is what I want.

    But I want to load it in one column 4 raws in the mobile devices. 

    How can I do this?

    Please can you advise me?

    Thanks!

    Wednesday, December 19, 2012 7:30 AM

All replies

  • User1648350404 posted

    You can do something like this:

     if (!Request.Browser.IsMobileDevice)
        {
    DataList1.RepeatDirection=RepeatDirection.Horizontal;
    }
    else{
    
    DataList1.RepeatDirection=RepeatDirection.Vertical;
    //...do something more for mobile devices
    }
    

    Wednesday, December 19, 2012 7:54 AM
  • User1407828493 posted

    Thank you very much for the reply. I used the code like this as your direction and it worked for me.

    if (!Request.Browser.IsMobileDevice)
            {
                dlCaseStudySearchResults.RepeatDirection = RepeatDirection.Horizontal;
                dlCaseStudySearchResults.RepeatColumns = 4;
                dlCaseStudySearchResults.BackColor = System.Drawing.Color.Red; // for testing
               
            }
            else
            {
    
                dlCaseStudySearchResults.RepeatDirection = RepeatDirection.Vertical;
                dlCaseStudySearchResults.RepeatColumns = 1;
                dlCaseStudySearchResults.BackColor = System.Drawing.Color.Blue; // for testing
                //...do something more for mobile devices
            }

    Anyway the code is not ditecting from mobile emulators. Tested with BG colors. But it is working actually on mobile devices.

    Thank you.

    Wednesday, December 19, 2012 9:24 AM
  • User1943143334 posted

    Hi,

    Request.Browser.IsMobileDevice may not work properly in all devices! Instead you can use the following techniques - 
    http://roopeshreddy.wordpress.com/2012/06/24/detect-requesting-device-type-and-redirect-in-asp-net/
    
    
    Hope it helps u...
    Wednesday, December 19, 2012 12:25 PM