Problem with EditableDesignerRegion and Set/Get methods ..

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Problem with EditableDesignerRegion and Set/Get methods ..

    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(EditableDesignerR egion region) {
    IDesignerHost host =
    (IDesignerHost)Component.Site.GetService(typeof(ID esignerHost));
    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(EditableDesignerR egion
    region, string content) {
    int currentstep = 0;
    if (content == null)
    return;
    try {
    IDesignerHost host =
    (IDesignerHost)Component.Site.GetService(typeof(ID esignerHost));
    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);
    }
    }


    Micke Andersson Guest

  2. Similar Questions and Discussions

    1. Adding controls to EditableDesignerRegion/ITemplate in code.
      I have a base custom control called 'WebBox' that contains a single EditableDesignerRegion. The contents of this EditableDesignerRegion are stored...
    2. Problem with Remote Methods
      Hello, I'm developing a very simple application that lets the user record his video on the server. But the user also need to be able to delete de...
    3. #26350 [NEW]: Inherited methods can't access private methods
      From: forseti at oak dot rpg dot pl Operating system: Windows 98 SE PHP version: 5.0.0b2 (beta2) PHP Bug Type: Zend Engine 2...
    4. odd problem calling object methods
      Hi. I was wondering whether anyone else could see anything wrong with this code: <input name="name" type="text" id="name" value="<?php print...
    5. Aliased setter methods behave differently than other methods?
      Here's another question... I am aliasing and redefining certain methods, determined at runtime. Normal methods work fine, but methods ending in '='...
  3. #2

    Default RE: Problem with EditableDesignerRegion and Set/Get methods ..

    Noone? :(

    "Micke Andersson" wrote:
    > 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 ..
    Micke Andersson Guest

  4. #3

    Default Re: Problem with EditableDesignerRegion and Set/Get methods ..

    hi Micke, I dont know the structure of your code logic and what you are
    doing exactly to get this problem. One of the things i have noticed when
    using designer regions and editabledesignerregions is that if i emit the
    call to base.SetViewFlags in the Initialize method of my designer class then
    unique ids are not maintained.


    /*
    * The designer host calls Initialize to initialize the component
    for design.
    * The base implementation will throw an exception if the associated
    * control does not implement the INamingContainer interface.
    */
    public override void Initialize(IComponent component)
    {
    this._c = (Tab)component;
    base.Initialize(component);
    // Seems like without setting ViewFalgs for TemplateEditing then
    // any control you add into the region does not maintain
    // a unique id :| No idea why this is the case but it dont
    bother me
    // to add this simple one line.
    base.SetViewFlags(ViewFlags.TemplateEditing, true);
    }

    if this did not fix your issue, then let me know and i'll try to put
    together a small test control with tabs and designer regions /
    editabledesignerregions working, to get you started.

    Regards,
    Alessandro Zifiglio
    [url]http://www.AsyncUI.net[/url]

    "Micke Andersson" <MickeAndersson@discussions.microsoft.com> ha scritto nel
    messaggio news:38D2DC9D-3C8E-4C2A-B2E3-4A20FE1AA885@microsoft.com...
    > Noone? :(
    >
    > "Micke Andersson" wrote:
    >
    >> 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 ..
    >

    Alessandro Zifiglio Guest

  5. #4

    Default Re: Problem with EditableDesignerRegion and Set/Get methods ..

    That actually appears to have fixed it. While I am not editing templates per
    se, I understand the logic behind it, kinda. Maybe they should have called
    that option something else - something more generic- if it just makes the
    designer aware of the fact that there's actually other web code living around
    it.

    Oh, and write some help past the automatically generated stuff once you get
    past looking for help about adding an onClick event :)

    Thanks a lot for helping out,
    /Micke

    "Alessandro Zifiglio" wrote:
    > hi Micke, I dont know the structure of your code logic and what you are
    > doing exactly to get this problem. One of the things i have noticed when
    > using designer regions and editabledesignerregions is that if i emit the
    > call to base.SetViewFlags in the Initialize method of my designer class then
    > unique ids are not maintained.
    Micke Andersson Guest

  6. #5

    Default Re: Problem with EditableDesignerRegion and Set/Get methods ..

    Your welcome, Micke. I agree that SetViewFlags is badly documented and named
    =P

    Regards,
    Alessandro Zifiglio
    [url]http://www.AsyncUI.net[/url]

    "Micke Andersson" <MickeAndersson@discussions.microsoft.com> ha scritto nel
    messaggio news:6476AEC0-037E-4938-81A8-8C8E0B56A397@microsoft.com...
    > That actually appears to have fixed it. While I am not editing templates
    > per
    > se, I understand the logic behind it, kinda. Maybe they should have called
    > that option something else - something more generic- if it just makes the
    > designer aware of the fact that there's actually other web code living
    > around
    > it.
    >
    > Oh, and write some help past the automatically generated stuff once you
    > get
    > past looking for help about adding an onClick event :)
    >
    > Thanks a lot for helping out,
    > /Micke
    >
    > "Alessandro Zifiglio" wrote:
    >
    >> hi Micke, I dont know the structure of your code logic and what you are
    >> doing exactly to get this problem. One of the things i have noticed when
    >> using designer regions and editabledesignerregions is that if i emit the
    >> call to base.SetViewFlags in the Initialize method of my designer class
    >> then
    >> unique ids are not maintained.
    >

    Alessandro Zifiglio Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139