PDA

View Full Version : [FIXED] [V0.8.0] Setting ScriptManager Theme to Default



davidhoyt
Dec 18, 2008, 6:32 AM
If you set a scriptmanager object's theme to something other than the default when first loaded and then change it to the default, it won't load (or Coolite.Ext.setTheme('Default') doesn't seem to work properly).

For example:


<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);


this.ScriptManager.Theme = Coolite.Ext.Web.Theme.Slate;
}


[AjaxMethod]
public string GetThemeUrl(string theme) {
var sm = this.ScriptManager;
Theme temp = (Theme)Enum.Parse(typeof(Theme), theme);
return (temp == Coolite.Ext.Web.Theme.Default || sm == null ? "Default" : sm.GetThemeUrl(temp));
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager" runat="server" HideInDesign="true" />
<ext:Panel runat="server" Header="false" Height="400" Border="false" EnableViewState="false">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:ToolbarButton Text="Home" Icon="HouseGo" runat="server">
<Listeners>
<Click Handler="alert('Home');" />
</Listeners>
</ext:ToolbarButton>
<ext:ToolbarFill />
<ext:ComboBox EmptyText="Choose Theme" Width="100px" Editable="false" TypeAhead="true" ID="selTheme" runat="server">
<Items>
<ext:ListItem Text="Default" Value="Default" />
<ext:ListItem Text="Gray" Value="Gray" />
<ext:ListItem Text="Slate" Value="Slate" />
</Items>
<Listeners>
<Select Handler="Coolite.AjaxMethods.GetThemeUrl(#{selTheme}.getVal ue(),{
success: function (result) {
Coolite.Ext.setTheme(result);
}
});" />
</Listeners>
</ext:ComboBox>
</Items>
</ext:Toolbar>
</TopBar>
<Body>
<div class="x-window-mc" style="height: 250px;">
Content Here


</Body>
</ext:Panel>
</form>
</body>
</html>

When the page loads it's using the slate theme. Set it to gray and it works just fine. But then set it to default and it never moves off gray.

Refresh the page and then immediately select default. It stays on slate. That seems like a bug to me.

davidhoyt
Dec 18, 2008, 6:43 AM
Refreshing the page, btw, isn't an option for us. Any thoughts?

davidhoyt
Dec 18, 2008, 10:51 PM
I'd like to bump this one to the "premium" category if I may. It's pretty important to us.

Perhaps I'll stop being lazy and go check it out for myself and propose a fix. Then again, maybe not... (c:

geoffrey.mcgill
Dec 22, 2008, 5:21 PM
Hi David,

Unfortunately this did not get fixed for v0.7 (ran out of time) but I will get this fixed asap. I have confirmed dynamically switching Theme's is an issue when a Theme otherthan "Default" is set on initial Page_Load.

davidhoyt
Jan 12, 2009, 10:42 PM
Any updates? (c:

Vladimir
Jan 27, 2009, 11:19 AM
Hi David,

We fixed SetTheme functionality. Please update from SVN

Here is test case:


<%@ Page Language="C#" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!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">
protected void Page_Load(object sender, EventArgs e)
{
if(!Ext.IsAjaxRequest)
{
ToDefault.Pressed = this.ScriptManager1.Theme == Coolite.Ext.Web.Theme.Default;
ToGray.Pressed = this.ScriptManager1.Theme == Coolite.Ext.Web.Theme.Gray;
ToSlate.Pressed = this.ScriptManager1.Theme == Coolite.Ext.Web.Theme.Slate;
}
}

protected void SetTheme(object sender, AjaxEventArgs e)
{
Theme theme = (Theme)Enum.Parse(typeof(Theme), e.ExtraParams["Theme"]);
this.ScriptManager1.SetTheme(theme);
}
</script>
</head>
<body style="margin: 10px;">
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" Theme="Slate" />

<ext:Button ID="ToDefault" runat="server" Text="Default" ToggleGroup="theme">
<AjaxEvents>
<Click OnEvent="SetTheme">
<ExtraParams>
<ext:Parameter Name="Theme" Value="Default" Mode="Value" />
</ExtraParams>
</Click>
</AjaxEvents>
</ext:Button>

<ext:Button ID="ToGray" runat="server" Text="Gray" ToggleGroup="theme">
<AjaxEvents>
<Click OnEvent="SetTheme">
<ExtraParams>
<ext:Parameter Name="Theme" Value="Gray" Mode="Value" />
</ExtraParams>
</Click>
</AjaxEvents>
</ext:Button>

<ext:Button ID="ToSlate" runat="server" Text="Slate" ToggleGroup="theme">
<AjaxEvents>
<Click OnEvent="SetTheme">
<ExtraParams>
<ext:Parameter Name="Theme" Value="Slate" Mode="Value" />
</ExtraParams>
</Click>
</AjaxEvents>
</ext:Button>

</form>
</body>
</html>



Please note that AjaxMethod from your example should be changed as the following


[AjaxMethod]
public string GetThemeUrl(string theme) {
var sm = this.ScriptManager;
Theme temp = (Theme)Enum.Parse(typeof(Theme), theme);
return sm.GetThemeUrl(temp));
}