[CLOSED] [1.0] DirectMethod - Page . UserControl . UserControl

  1. #1

    [CLOSED] [1.0] DirectMethod - Page . UserControl . UserControl

    I have a page which places a Class (as usercontrol) :

    protected void Page_Load(object sender, EventArgs e)
    {
        this.AdoreWidgetForm.Controls.Add(new AdoreEditor() { CodedID = HttpContext.Current.Request["EditorID"].ToString() });
    }
    In this class I load a certain Masterpage and I place some Ext.Net.Panels
    Each panel gets a toolbar:

    Panel WidgetPanel = this.BuildWidgetPanel(Widget.PageWidgetId, Widget.WidgetFile, "Widget");
    WidgetPanel.Tools.AddRange(PanelTools());
    private ToolsCollection PanelTools()
    {
        ToolsCollection tlc = new ToolsCollection();
        Tool CloseButton = new Tool();
        CloseButton.Qtip = "Close";
        CloseButton.Type = ToolType.Close;
        CloseButton.Handler = "#{DirectMethods}.CloseWidget();";
        tlc.Add(CloseButton);
        Tool EditButton = new Tool();
        EditButton.Qtip = "Edit";
        EditButton.Type = ToolType.Gear;
        tlc.Add(EditButton);
        return tlc;
    }
    I can't get the CloseWidget to execute, I have tried almost everything to reach the method but without succes.

    Any thoughts?
  2. #2

    RE: [CLOSED] [1.0] DirectMethod - Page . UserControl . UserControl

    Hi,


    I am not sure that clear understood your example structure. Where is the DirectMethod placed? Inside user control? Where is that panel placed? Inside the user control also (the same user control as for direct method)?


    Please create simple example which demonstrats the problem
  3. #3

    RE: [CLOSED] [1.0] DirectMethod - Page . UserControl . UserControl

    Hi Vladsch,

    I have found the problem, but not yet a solution. Maybe you can help me out here:

    I made small test of the basics:

    On PageX.aspx I load an UserControl:

    
    
    
    protected void Page_Load(object sender, EventArgs e)
    {
        AdoreEditor ed = new AdoreEditor();
        this.form1.Controls.Add(ed);
    }
    The Class of AdoreEditor :

    
    
    
    
    using System;
    using System.Web;
    using System.Collections.Generic;
    using System.Linq;
    using System.Xml.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.IO;
    using Ext;
    using Ext.Net;
    
    
    /// <summary>
    
    
    /// Summary description for AdoreEditor
    
    
    /// </summary>
    
    
    public class AdoreEditor : System.Web.UI.UserControl
    
    
    {
    
    
    protected override void OnLoad(EventArgs e)
    
    
    {
    
    
    this.ID = "AdoreEditorControl";
    
    
    this.Controls.Add(new Ext.Net.ResourceManager() { ID = "AdoreResourceManager" });
    
    
    BuildGUI();
    
    
    }
    
    
    private void BuildGUI()
    
    
    {
    
    
    Viewport AdoreEditorVP = new Viewport();
    
    
    AdoreEditorVP.ID = "AdoreEditorVP";
    
    
    AdoreEditorVP.IDMode = IDMode.Static;
    
    
    BorderLayout borderLayout = new BorderLayout();
    
    
    borderLayout.East.Collapsible = true;
    
    
    borderLayout.East.MinWidth = 160;
    
    
    borderLayout.East.MaxWidth = 160;
    
    
    borderLayout.East.MarginsSummary = "5 5 0 5";
    
    
    borderLayout.East.CMarginsSummary = "5 5 5 5";
    
    
    borderLayout.Center.MarginsSummary = "5 5 5 5";
    
    
    borderLayout.East.Items.Add(new Panel() { Width = 160, Html = "Toolbox for later user!" });
    
    
    borderLayout.Center.Items.Add(BuildRenderPage());
    
    
    DropTarget dt = new DropTarget();
    
    
    dt.Target = "${.adoreeditordroppanel}";
    
    
    dt.Group = "DropPanelsDD";
    
    
    dt.OverClass = "invite";
    
    
    dt.NotifyDrop.Handler = "this.el.appendChild(data.panel.el);";
    
    
    dt.NotifyOver.Handler = "Ext.select('.adoreeditordroppanel').removeClass('invite'); this.el.addClass('invite');";
    
    
    AdoreEditorVP.Items.Add(borderLayout);
    
    
    this.Controls.Add(AdoreEditorVP);
    
    
    this.Controls.Add(dt);
    
    
    }
    
    
    private Panel BuildRenderPage()
    
    
    {
    
    
    Panel PageContainer = new Panel();
    
    
    PageContainer.AutoScroll = true;
    
    
    PageContainer.DirectEvents.Render.ViewStateMode = ViewStateMode.Enabled;
    
    
    PageContainer.DirectEvents.AfterRender.EventMask.ShowMask = true;
    
    
    PageContainer.DirectEvents.AfterRender.EventMask.Msg = "Busy loading page configuration";
    
    
    PageContainer.DirectEvents.AfterRender.Event += new ComponentDirectEvent.DirectEventHandler(Render_Page_Event);
    
    
    PageContainer.ID = "PC";
    
    
    string masterFile = @"C:\Projects\Adore\Masterpages\template_1.master";
    
    
    if (File.Exists(masterFile))
    
    
    {
    
    
    string path = masterFile;
    
    
    string HtmlBase = File.ReadAllText(path);
    
    
    Regex formSearch = new Regex(@"(.*<\s*form[^>]*>)|(<\s*/\s*form\s*\>.+)", RegexOptions.Multiline);
    
    
    string FormBase = formSearch.Split(HtmlBase)[2];
    
    
    string BaseTemplate = Regex.Replace(FormBase, @"(<asp:ContentPlaceHolder[^>]*>[^>]*</asp:ContentPlaceHolder>)", new MatchEvaluator(GeneratePlaceHolder));
    
    
    Regex cssSearch = new Regex(@"(?:<link rel=""stylesheet"" .*?href=[""'](?<url>.*?)[""'].*?/>)");
    
    
    Regex dropZones = new Regex(@"(?:<asp:ContentPlaceHolder .*?id=[""'](?<id>.*?)[""'].*?/>)");
    
    
    foreach (Match m in cssSearch.Matches(HtmlBase))
    
    
    {
    
    
    System.Web.UI.HtmlControls.HtmlLink newStyleSheet = new System.Web.UI.HtmlControls.HtmlLink();
    
    
    newStyleSheet.Href = m.Groups["url"].Value;
    
    
    newStyleSheet.Attributes.Add("type", "text/css");
    
    
    newStyleSheet.Attributes.Add("rel", "stylesheet");
    
    
    Page.Header.Controls.Add(newStyleSheet);
    
    
    }
    
    
    PageContainer.Html = BaseTemplate;
    
    
    }
    
    
    return PageContainer;
    
    
    }
    
    
    protected void Render_Page_Event(object sender, DirectEventArgs e)
    
    
    {
    
    
    string message = string.Empty;
    
    
    int i = 1;
    
    
    Panel WidgetPanel = this.BuildWidgetPanel("PWID" + i.ToString(), "TITLE " + i.ToString(), "Widget");
    
    
    WidgetPanel.Cls = "PWI" + i.ToString();
    
    
    WidgetPanel.DraggableConfig.Group = "DropPanelsDD";
    
    
    WidgetPanel.Draggable = true;
    
    
    WidgetPanel.Closable = true;
    
    
    WidgetPanel.DraggableConfig.StartDrag.Handler = "Ext.select('.adoreeditordropPanel').addClass('x-drop-marker');";
    
    
    WidgetPanel.DraggableConfig.EndDrag.Handler = "Ext.select('.adoreeditordropPanel').removeClass('x-drop-marker');";
    
    
    WidgetPanel.Collapsible = true;
    
    
    WidgetPanel.Tools.AddRange(PanelTools());
    
    
    WidgetPanel.Html = "<p>Hallo&amp;nbsp;</p><p>&amp;nbsp;</p><p>&amp;nbsp;</p><p>&amp;nbsp;</p>";
    
    
    WidgetPanel.Render("aec_contentcntr", RenderMode.RenderTo);
    
    
    
    
    
    }
    
    
    [DirectMethod]
    
    
    public void ClosePanel()
    
    
    {
    
    
    Ext.Net.X.Msg.Alert("Name", "NAAM?").Show();
    
    
    }
    
    
    private ToolsCollection PanelTools()
    
    
    {
    
    
    ToolsCollection tlc = new ToolsCollection();
    
    
    Tool CloseButton = new Tool();
    
    
    CloseButton.Qtip = "Close";
    
    
    CloseButton.Type = ToolType.Close;
    
    
    CloseButton.Handler = "#{DirectMethods}.ClosePanel();";
    
    
    tlc.Add(CloseButton);
    
    
    Tool EditButton = new Tool();
    
    
    EditButton.Qtip = "Edit";
    
    
    EditButton.Type = ToolType.Gear;
    
    
    tlc.Add(EditButton);
    
    
    return tlc;
    
    
    }
    
    
    private Panel BuildWidgetPanel(string PageWidgetId, string Title, string Html)
    
    
    {
    
    
    return this.Page.X().Panel()
    
    
    .ID("aep" + PageWidgetId)
    
    
    .Title(Title)
    
    
    .AutoShow(true)
    
    
    .Padding(5)
    
    
    .Closable(true)
    
    
    .SetAutoScroll(true);
    
    
    }
    
    
    
    
    
    private static string GeneratePlaceHolder(Match m)
    
    
    {
    
    
    string Holder = m.Value;
    
    
    Holder = Holder.Replace("asp:ContentPlaceHolder", "div");
    
    
    Holder = Holder.Replace("runat=\"server\"", "class=\"adoreeditordroppanel\"");
    
    
    Holder = Holder.Replace("id=\"", "id=\"aec_");
    
    
    Holder = Holder.ToLower();
    
    
    return Holder;
    
    
    }
    
    
    }
    The problem is as following, when I change the Page_load event to
    
    if(!X.IsAjaxRequest){
        this.Controls.Add(new Ext.Net.ResourceManager() { ID = "AdoreResourceManager" });
        BuildGUI();
    }
    The function is found. But I need to use the DirectMethod (onAfterRender)

    PageContainer.DirectEvents.AfterRender.Event += new ComponentDirectEvent.DirectEventHandler(Render_Page_Event);
    So I can't you check for the AjaxRequest....
    Is there any other way solve this issue?


    Hope everything is a bit more clear for you
  4. #4

    RE: [CLOSED] [1.0] DirectMethod - Page . UserControl . UserControl


    The !X.IsAjaxRequest doesn't do anything after all..
    So the problem is still the same when I check for the event or not.

  5. #5

    RE: [CLOSED] [1.0] DirectMethod - Page . UserControl . UserControl



    The problem is solved, I have changed the DirectMethod as following:

    [DirectMethodProxyID(IDMode = DirectMethodProxyIDMode.Alias, Alias = "AEUC")]
    CloseButton.Handler = "Ext.net.DirectMethods.AEUC.ClosePanel();";

    Consider it solved!

Similar Threads

  1. Replies: 1
    Last Post: May 29, 2013, 6:00 PM
  2. Help me dont work UserControl directmethod. plz
    By SeoNamseok in forum 2.x Help
    Replies: 0
    Last Post: Jul 09, 2012, 8:19 AM
  3. [CLOSED] DirectMethod with UserControl Problem
    By nhg_itd in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 21, 2011, 8:00 AM
  4. [CLOSED] DirectMethod and UserControl
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 21, 2010, 7:15 PM
  5. [CLOSED] XRender UserControl DirectMethod
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Jan 22, 2010, 1:03 PM

Posting Permissions