Oct 14, 2010, 10:37 AM
[CLOSED] Direct events in user control
Hi
I don't know how to implement the directevents in my user control as follows:
... (I lost a bit overview when to use which technique. ... "loadcontrol" prefixed taged controls? typed controls? )
- A further question is how to define the direct events in the class in the top of this post.
What is your opionon? Your advice on that?
I don't know how to implement the directevents in my user control as follows:
using System;
using System.Web;
using Ext.Net;
namespace BPM.MVC.ViewControls
{
public class ThemeMenu : Ext.Net.Menu
{
// Change theme
protected void ChangeTheme(object sender, DirectEventArgs e)
{
Theme myTheme = (Theme)Enum.Parse(typeof(Theme), e.ExtraParams["myTheme"]);
Ext.Net.ResourceManager.GetInstance(HttpContext.Current).SetTheme(myTheme);
HttpContext.Current.Session["Ext.Net.Theme"] = myTheme;
//((CheckMenuItem)sender).Checked = true;
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
this.Add(new CheckMenuItem {
Text = "Default",
Group = "Theme",
Checked = ResourceManager.GetInstance(HttpContext.Current).Theme == Ext.Net.Theme.Default ? true : false
});
this.Add(new CheckMenuItem
{
Text = "Gray",
Group = "Theme",
Checked = ResourceManager.GetInstance(HttpContext.Current).Theme == Ext.Net.Theme.Gray ? true : false
});
this.Add(new CheckMenuItem
{
Text = "Slate",
Group = "Theme",
Checked = ResourceManager.GetInstance(HttpContext.Current).Theme == Ext.Net.Theme.Slate ? true : false
});
}
}
}
The original declarative code was as follows:<ext:Menu ID="Menu1" runat="server">
<Items>
<ext:CheckMenuItem runat="server" ID="myThemeDefault" Text="Default" Group="Theme">
<DirectEvents>
<Click OnEvent="ChangeTheme">
<ExtraParams>
<ext:Parameter Name="myTheme" Value="Default" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:CheckMenuItem>
<ext:CheckMenuItem runat="server" ID="myThemeGray" Text="Gray" Group="Theme">
<DirectEvents>
<Click OnEvent="ChangeTheme">
<ExtraParams>
<ext:Parameter Name="myTheme" Value="Gray" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:CheckMenuItem>
<ext:CheckMenuItem runat="server" ID="myThemeSlate" Text="Slate" Group="Theme">
<DirectEvents>
<Click OnEvent="ChangeTheme">
<ExtraParams>
<ext:Parameter Name="myTheme" Value="Slate" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:CheckMenuItem>
</Items>
</ext:Menu>
The control is used in the page as follows (Page excerpt):
<ext:MenuItem runat="server" Text="Theme" Icon="Paintcan">
<Menu>
<bpm:ThemeMenu runat="server" />
</Menu>
</ext:MenuItem>
- Actualy i'm not sure if this is the rigth way to encapsule simple functionality used at main level. (Theme change etc.)... (I lost a bit overview when to use which technique. ... "loadcontrol" prefixed taged controls? typed controls? )
- A further question is how to define the direct events in the class in the top of this post.
What is your opionon? Your advice on that?
Last edited by Daniil; Oct 14, 2010 at 6:58 PM.
Reason: [CLOSED]