SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Change gridview skin

    I want to change the skin for a gridview using code behind, so that it has a different skin when view on mobile devices. How do I do this?

    I have tried this but it doesn't work:

    if (Request.Browser.IsMobileDevice)
    {
    gvContacts.SkinID = "NPTResults_m";
    }

    cheers
    monkey - the rest is history

  2. #2
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    660
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    So, I take it your are developing for the Windows Phone, as you are using C#? Instead of Java/Android or Objective-C/IPhone?

    Unless, I'm not aware of .NET being ported to to the other devices.

    And how are you going to view the skin results on an IPhone/Andriod, if C# is not supported?

    NightStalker can add more.

  3. #3
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by USPaperchaser View Post
    So, I take it your are developing for the Windows Phone, as you are using C#? Instead of Java/Android or Objective-C/IPhone?

    Unless, I'm not aware of .NET being ported to to the other devices.

    And how are you going to view the skin results on an IPhone/Andriod, if C# is not supported?

    NightStalker can add more.
    spot on - internal system therefore i can guarantee the mobile devices used are windows mobile (aren't I lucky!)
    monkey - the rest is history

  4. #4
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    660
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Try something like so:


    Code Csharp:
    string strUserAgent = Request.UserAgent.ToString().ToLower();
    if (strUserAgent != null)
    {
    if (Request.Browser.IsMobileDevice == true ||
    strUserAgent.Contains("windows ce"))
     
    {
    //If ya smell what The Rock is cooking!
    }
    }

  5. #5
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by USPaperchaser View Post
    Try something like so:


    Code Csharp:
    string strUserAgent = Request.UserAgent.ToString().ToLower();
    if (strUserAgent != null)
    {
    if (Request.Browser.IsMobileDevice == true ||
    strUserAgent.Contains("windows ce"))
     
    {
    //If ya smell what The Rock is cooking!
    }
    }

    Sorry - should have siad i have this bit working - it is the changes the gridview skin that isn't!
    cheers
    monkey - the rest is history

  6. #6
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by USPaperchaser View Post
    ... If ya smell what The Rock is cooking! ...
    Did I go back in time?

    Hmm. I may have to look into WinPhone dev. This is interesting.

  7. #7
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    660
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imaginekitty View Post
    Did I go back in time?
    Yeah, I'm 26, and STILL a fan of wrasslin! HA! It's a soap opera for guys...





    Hmm. I may have to look into WinPhone dev. This is interesting.

    Ditto. Although, I'm not going to jump-in for at least 2 years. Let it mature and saturate the market, to see where Win Phone is going. It is still a baby compared to the 20'something IPhone and Android. Besides that, I don't plan on jumping on the mobile development bandwagon, as a whole, for awhile. Need to stay focused on WPF and ASP.NET. Knowledge of all....master of none.

  8. #8
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by USPaperchaser View Post
    ... Need to stay focused on WPF and ASP.NET. Knowledge of all....master of none.
    I would imagine WPF would cover both. Is WinPhone dev based on Silverlight?

  9. #9
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    660
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imaginekitty View Post
    I would imagine WPF would cover both. Is WinPhone dev based on Silverlight?
    Opps! Brain lapse, yes XAMP is used on both. It's morning, and I haven't had my Red Bull, forgive me.

  10. #10
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    STOP YOU JIBBERING ABOUT WRESTLING FOOLS OR I'LL GET YOU DOWN AND KICK YO ASS!!! (said in my best deep wrestling shouty voice! )


    I can't see WinMobile going anywhere anytime soon. Mobile devices are the future and I can't see MS letting that slip though their fingers!

    Anyway - this isn't fixing my problem - focus people
    monkey - the rest is history

  11. #11
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    660
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by boxhead View Post
    I want to change the skin for a gridview using code behind, so that it has a different skin when view on mobile devices. How do I do this?

    I have tried this but it doesn't work:

    if (Request.Browser.IsMobileDevice)
    {
    gvContacts.SkinID = "NPTResults_m";
    }

    cheers
    Sorry, I have a problem of always getting off topic.

    Can you show me the code/markup for: NPTResults_m

  12. #12
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in a file called App_Themes\Default\gridview.skin

    Code:
    <asp:GridView runat="server" SkinID="NPTResults_m" AllowPaging="True" AllowSorting="True" PageSize="50" AutoGenerateColumns="False"
    	CellPadding="1" CellSpacing="0">	        
        <HeaderStyle CssClass="FieldNameFont" ForeColor="#111111" HorizontalAlign="Left" VerticalAlign="Top" BorderStyle="Solid" BorderWidth="0px" BorderColor="#c0c0c0"/>
        <RowStyle CssClass="FieldValueFont" BackColor="#ffffff" VerticalAlign="Top" BorderStyle="Solid" BorderWidth="0px" BorderColor="#cacaca" />
        <AlternatingRowStyle CssClass="FieldValueFont" BackColor="#ebebf3" VerticalAlign="Top" BorderStyle="Solid" BorderWidth="0px" BorderColor="#cacaca" />
        <PagerSettings Position="TopAndBottom" Mode="NumericFirstLast" />
        <PagerStyle BackColor="#ffffff" HorizontalAlign="Center" CssClass="FieldNameFont" />
        <EmptyDataRowStyle CssClass="FieldValueFont" />
    </asp:GridView>
    mostley it makes the gridviews more compact for mobile devices but other things may chnage as well.

    cheers
    monkey - the rest is history

  13. #13
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    660
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by boxhead View Post
    in a file called App_Themes\Default\gridview.skin

    Code:
    <asp:GridView runat="server" SkinID="NPTResults_m" AllowPaging="True" AllowSorting="True" PageSize="50" AutoGenerateColumns="False"
    	CellPadding="1" CellSpacing="0">	        
        <HeaderStyle CssClass="FieldNameFont" ForeColor="#111111" HorizontalAlign="Left" VerticalAlign="Top" BorderStyle="Solid" BorderWidth="0px" BorderColor="#c0c0c0"/>
        <RowStyle CssClass="FieldValueFont" BackColor="#ffffff" VerticalAlign="Top" BorderStyle="Solid" BorderWidth="0px" BorderColor="#cacaca" />
        <AlternatingRowStyle CssClass="FieldValueFont" BackColor="#ebebf3" VerticalAlign="Top" BorderStyle="Solid" BorderWidth="0px" BorderColor="#cacaca" />
        <PagerSettings Position="TopAndBottom" Mode="NumericFirstLast" />
        <PagerStyle BackColor="#ffffff" HorizontalAlign="Center" CssClass="FieldNameFont" />
        <EmptyDataRowStyle CssClass="FieldValueFont" />
    </asp:GridView>
    mostley it makes the gridviews more compact for mobile devices but other things may chnage as well.

    cheers
    Here you go bro. You need Silverlight and XAML to complete your solution.

    http://stackoverflow.com/questions/2...indows-phone-7

    OR,

    http://www.silverlightshow.net/items...ne-Part-1.aspx

  14. #14
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by USPaperchaser View Post
    Cheers buddy. I'll have a look Monday morning - time to go home now (sorry but that's time diffs for you! )

    We don't uses Windows Phone 7 but may do in the future and will give me a starting point anyway

    have a good weekend all!
    monkey - the rest is history


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •