[CLOSED] How to change theme from the client side

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] How to change theme from the client side

    We tried to copy the combobox (from the example page) with the javascript call to change the theme, but nothing happens. Can you give me an example of how to do this?
    Last edited by Vladimir; Jul 13, 2010 at 10:54 AM.
  2. #2
    Hi,

    I am not sure that can provide another example. You need to get theme url on the server side and set that url on the client side

    [DirectMethod]
        public string GetThemeUrl(string theme)
        {
            Theme temp = (Theme)Enum.Parse(typeof(Theme), theme);
    
            this.Session["Ext.Net.Theme"] = temp;
    
            return (temp == Ext.Net.Theme.Default) ? "Default" : this.ResourceManager1.GetThemeUrl(temp);
        }
    <ItemClick Handler="Ext.net.DirectMethods.GetThemeUrl(menuItem.text,{
    	success : function (result) {
    		Ext.net.ResourceMgr.setTheme(result);
    	}
    });" />
    Can you provide test sample which demosntrates that Theme is not working for you
  3. #3
    Do I have to do anything after? While I'm not getting an error, it's not actually changing any of the controls.
  4. #4
    Quote Originally Posted by jmcantrell View Post
    Do I have to do anything after? While I'm not getting an error, it's not actually changing any of the controls.
    Please post a code sample demonstrating how you have things configured. We're stabbing in the dark trying to give you suggestions without seeing what you're actually doing.
    Geoffrey McGill
    Founder
  5. #5
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
    
        <script runat="server">
            
            <DirectMethod()> _
            Public Function GetThemeUrl(ByVal theme As String) As String
                Dim temp As Ext.Net.Theme = [Enum].Parse(GetType(Ext.Net.Theme), theme)
                Session("Ext.Net.Theme") = temp
                Return If(temp = Ext.Net.Theme.Default, "Default", ResourceManager1.GetThemeUrl(temp))
            End Function
                
        </script>
        
        <script type="text/javascript">
    
            var setTheme = function(value) {
                Ext.net.DirectMethods.GetThemeUrl(value, {
                    success: function(result) {
                        Ext.net.ResourceMgr.setTheme(result);
                    }
                });
            };
            
        </script>
    
    </head>
    <body>
        <form id="form1" runat="server">
        
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <ext:Viewport ID="MainViewport" runat="server">
                <Items>
                    <ext:BorderLayout ID="MainBorderLayout" runat="server">
                        <North Margins-Bottom="4">
                            <ext:Panel ID="Panel1" runat="server" Header="false" Height="100">
                                <Content>
                                    <ext:ComboBox ID="StyleSwitcher" runat="server" Width="250" SelectedIndex="0">
                                        <Items>
                                            <ext:ListItem Text="Blue Theme (Default)" Value="default" />
                                            <ext:ListItem Text="Gray Theme" Value="gray" />
                                            <ext:ListItem Text="Accessibility Theme" Value="access" />
                                            <ext:ListItem Text="Slate Theme" Value="slate" />
                                        </Items>
                                        <Listeners>
                                            <Select Handler="setTheme(#{StyleSwitcher}.getValue());" />
                                        </Listeners>
                                    </ext:ComboBox>
                                </Content>
                            </ext:Panel>
                        </North>
                        <West MinWidth="250" Split="true" Collapsible="true">
                            <ext:Panel ID="SidePanel" runat="server" Width="250" Header="false">
                                <Content>
                                    WEST
                                </Content>
                            </ext:Panel>
                        </West>
                        <Center Split="true" Collapsible="true">
                            <ext:Panel ID="BottomPanel" runat="server" Header="false">
                                <Content>
                                    CENTER
                                </Content>
                            </ext:Panel>
                        </Center>
                    </ext:BorderLayout>
                </Items>
            </ext:Viewport>
            
        </form>
    </body>
    </html>
  6. #6
    Hi,

    You use small cases themes names therefore Enum cannot parse theme. Change first letter of themes to upper case (like Value="Slate") or Enum must ignore case (pass true for the third argument to the Parse method)
    Ext.Net.Theme temp = (Ext.Net.Theme)Enum.Parse(typeof(Ext.Net.Theme), theme, true);
  7. #7
    That worked.
  8. #8
    I add this code to my project. But when i choose a Theme... it's only applied to the current Tab.

    Only when I press F5 all page have the theme was I choose.

    How can I do to apply in the others tabs opened (entire project?) without press F5?

    This code Apply for ResourceManagerMaster1
    [DirectMethod]
            public string GetThemeUrl(string theme)
            {
                Theme temp = (Theme)Enum.Parse(typeof(Theme), theme, true);
     
                this.Session["Ext.Net.Theme"] = temp;
    
                return (temp == Ext.Net.Theme.Default) ? "Default" : this.ResourceManagerMaster1.GetThemeUrl(temp);
            }
    I need to rename all the resorce manager in the entire project to ResourceManager1?
    Last edited by inaltec; Jul 18, 2012 at 4:19 PM.
  9. #9
    Well, I guess each tab contains an iframe, isn't that so?

    Then you should call that code for all iframe pages.
  10. #10
    Sorry... but... I don't understand how can I do this.

    have you a complete example for Theme implemtation?

    or an example how can I call this function for all iFrame?
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Client side change component handler function....
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 24, 2012, 3:54 PM
  2. [CLOSED] How to change the pressed status for button in client side
    By leon_tang in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 23, 2012, 3:08 PM
  3. Replies: 3
    Last Post: Dec 26, 2011, 1:32 PM
  4. [CLOSED] Change fieldLabel on client-side
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 28, 2010, 5:18 PM
  5. [CLOSED] ScriptManager Theme to Default (Client side)
    By davidhoyt in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 22, 2008, 4:20 PM

Posting Permissions