M
Micke Andersson
I have a slight problem with
SetEditableDesignerRegionContent(region,content) .. it keeps telling me that
I already have a control with the same ID when I try to update, thus failing
and somehow actually adding stuff twice ..
so what am I doing wrong? I have a custom control which contains a list of
other controls (TabControl and a list of Tabs), but I cannot use templates
since I want attributes on the Tabs themselves). It all works runtime - and
in the designer - but on and off when I do certain changes, I cannot persist
the EditableDesignerRegion contents due to contents apparently appearing
twice.
The designer is actually bound to the TabControl, but actually what I am
editing is the contents of the Tab - the TabControl selects what Tab is
active dynamically so I don't really know how to do it another way. I'm
pretty certain the problem is at or near the GetEditable...() and
SetEditable...() functions, so can anyone give me a hint on how to persist
Tab data from the designer correctly?
I tried looking at information about ControlParser and ControlPersister, but
there's not a lot out there that i can can find
EditableDesignerRegion is created from a <div> tag surrounding each tab
(generated by TabControl.Render()) and is filled with the designer mark
(__designer="0" in this case) when in design mode.
/Micke Andersson
public override string
GetEditableDesignerRegionContent(EditableDesignerRegion region) {
IDesignerHost host =
(IDesignerHost)Component.Site.GetService(typeof(IDesignerHost));
try {
if (host != null) {
Tab tab = _c.Tabs[region.Name];
string s = "";
foreach (Control cc in tab.Controls) {
s += ControlPersister.PersistControl(cc, host);
}
return s;
}
} catch (Exception ex) {
_(" EXCEPTION: " + ex.Message);
}
return "";
}
public override void SetEditableDesignerRegionContent(EditableDesignerRegion
region, string content) {
int currentstep = 0;
if (content == null)
return;
try {
IDesignerHost host =
(IDesignerHost)Component.Site.GetService(typeof(IDesignerHost));
if (host != null) {
Tab tab = _c.Tabs[region.Name];
tab.Controls.Clear();
Control[] c = ControlParser.ParseControls(host, content);
foreach (Control cc in c) {
tab.Controls.Add(cc);
}
}
} catch (Exception ex) {
_(" EXCEPTION: " + ex.Message);
}
}
SetEditableDesignerRegionContent(region,content) .. it keeps telling me that
I already have a control with the same ID when I try to update, thus failing
and somehow actually adding stuff twice ..
so what am I doing wrong? I have a custom control which contains a list of
other controls (TabControl and a list of Tabs), but I cannot use templates
since I want attributes on the Tabs themselves). It all works runtime - and
in the designer - but on and off when I do certain changes, I cannot persist
the EditableDesignerRegion contents due to contents apparently appearing
twice.
The designer is actually bound to the TabControl, but actually what I am
editing is the contents of the Tab - the TabControl selects what Tab is
active dynamically so I don't really know how to do it another way. I'm
pretty certain the problem is at or near the GetEditable...() and
SetEditable...() functions, so can anyone give me a hint on how to persist
Tab data from the designer correctly?
I tried looking at information about ControlParser and ControlPersister, but
there's not a lot out there that i can can find
EditableDesignerRegion is created from a <div> tag surrounding each tab
(generated by TabControl.Render()) and is filled with the designer mark
(__designer="0" in this case) when in design mode.
/Micke Andersson
public override string
GetEditableDesignerRegionContent(EditableDesignerRegion region) {
IDesignerHost host =
(IDesignerHost)Component.Site.GetService(typeof(IDesignerHost));
try {
if (host != null) {
Tab tab = _c.Tabs[region.Name];
string s = "";
foreach (Control cc in tab.Controls) {
s += ControlPersister.PersistControl(cc, host);
}
return s;
}
} catch (Exception ex) {
_(" EXCEPTION: " + ex.Message);
}
return "";
}
public override void SetEditableDesignerRegionContent(EditableDesignerRegion
region, string content) {
int currentstep = 0;
if (content == null)
return;
try {
IDesignerHost host =
(IDesignerHost)Component.Site.GetService(typeof(IDesignerHost));
if (host != null) {
Tab tab = _c.Tabs[region.Name];
tab.Controls.Clear();
Control[] c = ControlParser.ParseControls(host, content);
foreach (Control cc in c) {
tab.Controls.Add(cc);
}
}
} catch (Exception ex) {
_(" EXCEPTION: " + ex.Message);
}
}