Design-Time Support for Composite Server Control in a Table

Discussion in 'ASP .Net Building Controls' started by brian.chandley@gmail.com, Jan 30, 2007.

  1. Guest

    I am creating a Composite Server Control (.NET 1.1), the Control is
    comprised of 3 Table Rows.
    It works perfectly well during run time, and when it is webform alone.
    The problem arises in the VS.net designer when the control is placed
    in a Table.

    <table >
    <CC1:TerritorySearch id="SYRTerritorySearch2" runat="server"></
    CC1:TerritorySearch>
    </table>


    It continues to work when it is rendered to the browser, but none of
    the controls are displayed in the VS.NET designer. The table is
    displayed, and any other rows I place in the table are displayed, just
    not the control I have developed shows up.

    I have created a very simple designer for the control that ensures the
    control collection is created prior to calling GetDesignTimeHtml.

    My question boils down to: Is there any thing that can be done to a
    control that needs to be nested in a table to enable simple design-
    time support?

    Other details that might be useful:
    The control inherits from System.Web.UI.WebControls.WebControl and
    Inplements INamingContainer

    I have tried rendering the control using the methods of the
    HtmlTextWriter class, and creating all the rows and Cells as
    HtmlTableCells and HtmlTableRows.

    Any input would be appreciated.

    Brian
     
    , Jan 30, 2007
    #1
    1. Advertising

  2. Peter Zolja Guest

    > <table >
    > <CC1:TerritorySearch id="SYRTerritorySearch2" runat="server"></
    > CC1:TerritorySearch>
    > </table>


    Is your control outputting the <tr> and <td> tags? Have you tried doing it
    like this?

    <table >
    <tr>
    <td>
    <CC1:TerritorySearch id="SYRTerritorySearch2"
    runat="server"></CC1:TerritorySearch>
    </td>
    </tr>
    </table>
     
    Peter Zolja, Jan 30, 2007
    #2
    1. Advertising

  3. Guest

    Thanks for your reply.
    The control outputs 3 Table rows:

    <tr>
    <td colspan=2>heading</td>
    </tr>.
    <tr>
    <td>Label</td>
    <td>Input</td>
    </tr>
    <tr>
    <td>anothe Label</td>
    <td>another Input</td>
    </tr>.

    I have also tried, with no luck.

    <TBody>
    <tr>
    <td colspan=2>heading</td>
    </tr>.
    <tr>
    <td>Label</td>
    <td>Input</td>
    </tr>
    <tr>
    <td>anothe Label</td>
    <td>another Input</td>
    </tr>.
    </TBody>

    Brian



    On Jan 30, 6:39 pm, "Peter Zolja" <> wrote:
    > > <table >
    > > <CC1:TerritorySearch id="SYRTerritorySearch2" runat="server"></
    > > CC1:TerritorySearch>
    > > </table>

    >
    > Is your control outputting the <tr> and <td> tags? Have you tried doing it
    > like this?
    >
    > <table >
    > <tr>
    > <td>
    > <CC1:TerritorySearch id="SYRTerritorySearch2"
    > runat="server"></CC1:TerritorySearch>
    > </td>
    > </tr>
    > </table>
     
    , Jan 31, 2007
    #3
  4. On Jan 31, 2:27 am, wrote:
    > Thanks for your reply.
    > The control outputs 3 Table rows:

    [snip]

    I can't really help you with your problem, however I can guide you
    into a direction that might give you a solution...
    The fact that you can infact attach to visual studio fro another
    visual studio instance and actually debug what happens during the
    DesignTime rendering is something very few people is aware of...
    I figure there's probably something going on that you don't know
    about!
    Attach to visual studio (Debug/Processes choose the OTHER visual
    studio process and click Attach)
    Then open the page in the designer in design view and wait for your
    breakpoint in the OTHER instance of visual studio to kick in (which
    you obviously must add to the Render or RenderControl method)

    Quite nifty feature that makes life very much easier for WebControl
    developers... :)

    ..t

    --
    http://ajaxwidgets.com
    Free ASP.NET Ajax Widgets NOW!
     
    Thomas Hansen, Jan 31, 2007
    #4
  5. Guest

    Thanks for the suggestion. I will try it out.
    Brian
    On Jan 31, 3:45 am, "Thomas Hansen" <> wrote:
    > On Jan 31, 2:27 am, wrote:> Thanks for your reply.
    > > The control outputs 3 Table rows:

    >
    > [snip]
    >
    > I can't really help you with your problem, however I can guide you
    > into a direction that might give you a solution...
    > The fact that you can infact attach to visual studio fro another
    > visual studio instance and actually debug what happens during the
    > DesignTime rendering is something very few people is aware of...
    > I figure there's probably something going on that you don't know
    > about!
    > Attach to visual studio (Debug/Processes choose the OTHER visual
    > studio process and click Attach)
    > Then open the page in the designer in design view and wait for your
    > breakpoint in the OTHER instance of visual studio to kick in (which
    > you obviously must add to the Render or RenderControl method)
    >
    > Quite nifty feature that makes life very much easier for WebControl
    > developers... :)
    >
    > .t
    >
    > --http://ajaxwidgets.com
    > Free ASP.NET Ajax Widgets NOW!
     
    , Jan 31, 2007
    #5
  6. Peter Zolja Guest

    > I have also tried, with no luck.
    >
    > <TBody>
    > <tr>
    > <td colspan=2>heading</td>
    > </tr>.
    > <tr>
    > <td>Label</td>
    > <td>Input</td>
    > </tr>
    > <tr>
    > <td>anothe Label</td>
    > <td>another Input</td>
    > </tr>.
    > </TBody>


    If you override WebControl you automatically get a <div> around your
    control; if your base class is Control you don't have this issue. In any
    case, I tried to do a simple test application and I got the same behavior.
    Putting the custom control within <table></table> would make it invisible in
    the designer. Mind you, it is doing this with the built-in controls as well,
    which leads me to believe it's a VS designer limitation.

    Is there any reason why your control can not output the <table> tag as well
    (in which case you'll be able to see the control in the designer)? If you'd
    give us more information about what you're trying to achieve we may be able
    to suggest a different approach.
     
    Peter Zolja, Jan 31, 2007
    #6
  7. Guest

    The desired affect is to take a portion of a search input form has a
    lot of Javascript and make it a standard part of many search pages.
    It presents the user with a series of options and validates selection,
    and limits selection based on who you are. This is not code I want to
    be copied and pasted. This control will be used across several web
    projects, so a UserControl is out of the question.

    An implementation would look like this:

    <table >
    <tr>
    <td>Site</td>
    <td><input ... > </td>
    </tr>
    <tr>
    <td>CIty</td>
    <td><input ... > </td>
    </tr>
    <CC1:TerritorySearch id="TerritorySearch2" runat="server"></
    CC1:TerritorySearch>
    </table>

    When The User executes his/her search, the code behind would read the
    Search type and Search value properties.

    Per Tom's suggestion, I used the debugger and my designer is being
    called, I wounder if it assumes that it is just a TR, which has no
    visible elements.

    For a moment, I thought I could inherit from the TableRowCollection,
    until I saw it is marked as sealed. I also hoped I could reach out to
    the parent and add the rows I created to it's TableRowCollection but
    this.Parent Is not a table, but the form.





    On Jan 31, 3:19 pm, "Peter Zolja" <> wrote:
    > > I have also tried, with no luck.

    >
    > > <TBody>
    > > <tr>
    > > <td colspan=2>heading</td>
    > > </tr>.
    > > <tr>
    > > <td>Label</td>
    > > <td>Input</td>
    > > </tr>
    > > <tr>
    > > <td>anothe Label</td>
    > > <td>another Input</td>
    > > </tr>.
    > > </TBody>

    >
    > If you override WebControl you automatically get a <div> around your
    > control; if your base class is Control you don't have this issue. In any
    > case, I tried to do a simple test application and I got the same behavior.
    > Putting the custom control within <table></table> would make it invisible in
    > the designer. Mind you, it is doing this with the built-in controls as well,
    > which leads me to believe it's a VS designer limitation.
    >
    > Is there any reason why your control can not output the <table> tag as well
    > (in which case you'll be able to see the control in the designer)? If you'd
    > give us more information about what you're trying to achieve we may be able
    > to suggest a different approach.
     
    , Feb 1, 2007
    #7
  8. Peter Zolja Guest

    > <table >
    > <tr>
    > <td>Site</td>
    > <td><input ... > </td>
    > </tr>
    > <tr>
    > <td>CIty</td>
    > <td><input ... > </td>
    > </tr>
    > <CC1:TerritorySearch id="TerritorySearch2" runat="server"></
    > CC1:TerritorySearch>
    > </table>


    How about making your control a composite control and have two string
    properties for "site" and "city" and two TextBoxes for input. If this is
    something you can't control (the first part of the table) I'd suggest you
    move your "TerritorySearch" control outside of the table and have it output
    another table, so the generate code would look like this:

    <table >
    <tr>
    <td>Site</td>
    <td><input ... > </td>
    </tr>
    <tr>
    <td>CIty</td>
    <td><input ... > </td>
    </tr>
    </table>
    <!-- code from TerritorySearch -->
    <table>
    <tr>
    <td>control output </td>
    </tr>
    </table>
     
    Peter Zolja, Feb 1, 2007
    #8
  9. Guest

    This looks like what I will need to do.
    Thanks for all your Time Peter,

    On Feb 1, 12:05 pm, "Peter Zolja" <> wrote:
    > > <table >
    > > <tr>
    > > <td>Site</td>
    > > <td><input ... > </td>
    > > </tr>
    > > <tr>
    > > <td>CIty</td>
    > > <td><input ... > </td>
    > > </tr>
    > > <CC1:TerritorySearch id="TerritorySearch2" runat="server"></
    > > CC1:TerritorySearch>
    > > </table>

    >
    > How about making your control a composite control and have two string
    > properties for "site" and "city" and two TextBoxes for input. If this is
    > something you can't control (the first part of the table) I'd suggest you
    > move your "TerritorySearch" control outside of the table and have it output
    > another table, so the generate code would look like this:
    >
    > <table >
    > <tr>
    > <td>Site</td>
    > <td><input ... > </td>
    > </tr>
    > <tr>
    > <td>CIty</td>
    > <td><input ... > </td>
    > </tr>
    > </table>
    > <!-- code from TerritorySearch -->
    > <table>
    > <tr>
    > <td>control output </td>
    > </tr>
    > </table>
     
    , Feb 2, 2007
    #9
  10. Guest

    Test, Please ignore

    <> wrote in message
    news:...
    > Thanks for the suggestion. I will try it out.
    > Brian
    > On Jan 31, 3:45 am, "Thomas Hansen" <> wrote:
    >> On Jan 31, 2:27 am, wrote:> Thanks for your
    >> reply.
    >> > The control outputs 3 Table rows:

    >>
    >> [snip]
    >>
    >> I can't really help you with your problem, however I can guide you
    >> into a direction that might give you a solution...
    >> The fact that you can infact attach to visual studio fro another
    >> visual studio instance and actually debug what happens during the
    >> DesignTime rendering is something very few people is aware of...
    >> I figure there's probably something going on that you don't know
    >> about!
    >> Attach to visual studio (Debug/Processes choose the OTHER visual
    >> studio process and click Attach)
    >> Then open the page in the designer in design view and wait for your
    >> breakpoint in the OTHER instance of visual studio to kick in (which
    >> you obviously must add to the Render or RenderControl method)
    >>
    >> Quite nifty feature that makes life very much easier for WebControl
    >> developers... :)
    >>
    >> .t
    >>
    >> --http://ajaxwidgets.com
    >> Free ASP.NET Ajax Widgets NOW!

    >
    >
     
    , Apr 3, 2007
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    747
  2. sleigh
    Replies:
    1
    Views:
    2,736
    sleigh
    Feb 12, 2004
  3. Replies:
    1
    Views:
    405
    Teemu Keiski
    Jul 2, 2003
  4. Chad
    Replies:
    0
    Views:
    252
  5. scsharma

    design time support for composite controls....

    scsharma, Aug 5, 2005, in forum: ASP .Net Web Controls
    Replies:
    9
    Views:
    256
    Steven Cheng[MSFT]
    Aug 9, 2005
Loading...

Share This Page