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&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&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