Custom Control Table member variable broke

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

  1. #1

    Default Custom Control Table member variable broke

    I have been trying for 2 weeks to figure out how to
    implement a table as a member variable that the user can
    setup with the property designer with no luck. The code
    below adds the table to the property designer, however it
    will not write the HTML associated with the TABLE within
    the custom server control tags unless you change the font
    property within the table. For instance you can set the
    ID of the table and its height and width then hit rebuild
    and it all gets blown away because the table does'nt get
    serialized.However set the ID,Width and Height again this
    time change the Font property of the table to bold and it
    magically writes the HTML code as shown in result 2,
    which is exactly correct and what I want. Changing any
    property value in the font of the table somehow triggers
    VS to write the correct HTML..but changing any of the
    table attributes doesnt do anything..you have to change
    the font to get it to make any change...............

    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.ComponentModel;
    using System.Drawing.Design;
    using System.Web.UI.Design;

    namespace RealGridII
    {
    /// <summary>
    /// Summary description for WebCustomControl1.
    /// </summary>

    [ToolboxData("<{0}:RealGridControl runat=server></
    {0}:RealGridControl>")]
    public class RealGridControl :
    System.Web.UI.WebControls.DataGrid
    {
    private Table m_myHeader;

    /// <summary>
    /// Constructor
    /// </summary>
    public RealGridControl()
    {
    m_myHeader = new Table();
    }

    [Category("LookHere"),NotifyParentProperty
    (true),DesignerSerializationVisibility
    (DesignerSerializationVisibility.Content),Persiste nceMode
    (PersistenceMode.InnerProperty)]
    public Table myDatagrid
    {
    get
    {
    return m_myHeader;
    }
    set
    {
    m_myHeader = value;
    }
    }

    /// <summary>
    /// Render this control to the output
    parameter specified.
    /// </summary>
    /// <param name="output"> The HTML writer
    to write out to </param>
    protected override void Render
    (HtmlTextWriter output)
    {
    m_myHeader.RenderControl(output);
    base.Render(output);

    }
    }
    }

    Result #1:
    <form id="Form1" method="post" runat="server">
    <cc1:realgridcontrol
    id="RealGridControl2" style="Z-INDEX: 101; LEFT: 400px;
    POSITION: absolute; TOP: 184px"
    runat="server"
    DataSource="<%# dataView1 %>" AutoGenerateColumns="False">

    <Columns>
    <asp:BoundColumn
    DataField="EmployeeID" SortExpression="EmployeeID"
    HeaderText="EmployeeID"></asp:BoundColumn>
    <asp:BoundColumn
    DataField="LastName" SortExpression="LastName"
    HeaderText="LastName"></asp:BoundColumn>
    <asp:BoundColumn
    DataField="FirstName" SortExpression="FirstName"
    HeaderText="FirstName"></asp:BoundColumn>
    </Columns>
    </cc1:realgridcontrol></form>



    Result #2
    <form id="Form1" method="post" runat="server">
    <cc1:realgridcontrol
    id="RealGridControl2" style="Z-INDEX: 101; LEFT: 400px;
    POSITION: absolute; TOP: 184px"
    runat="server"
    DataSource="<%# dataView1 %>" AutoGenerateColumns="False">
    <myDatagrid Font-
    Bold="True" ID="fuku"></myDatagrid>
    <Columns>
    <asp:BoundColumn
    DataField="EmployeeID" SortExpression="EmployeeID"
    HeaderText="EmployeeID"></asp:BoundColumn>
    <asp:BoundColumn
    DataField="LastName" SortExpression="LastName"
    HeaderText="LastName"></asp:BoundColumn>
    <asp:BoundColumn
    DataField="FirstName" SortExpression="FirstName"
    HeaderText="FirstName"></asp:BoundColumn>
    </Columns>
    </cc1:realgridcontrol></form>
    Troy Guest

  2. Similar Questions and Discussions

    1. Custom table names for Client variable storage
      I'm wondering if it's possible to change the name of the tables ColdFusion uses to store client variables in a data source. I'm setting up a...
    2. Building a custom table control
      Hi Everyone, I am new to Server control development and I need some serious help with something. I want to build a control that will allow the...
    3. Sending a session variable to a custom control
      I have the following code in my aspx page which calls my custom control (this works): <cc1:matextbox id="matextbox1" runat="server">...
    4. Building a custom control that implement table server control
      Hi, I want to create a custom control that implements the table htmlcontrol. In my webform page I want to include that custom control and add...
    5. Using Table control in a custom composite control. Control does not render properly in design time.
      All, I have written a very simple custom composite control that includes a control of type System.Web.UI.WebControls.Table. The control...
  3. #2

    Default Re: Custom Control Table member variable broke

    Hi,

    If you are looking for "UI type editor"[1] then I didn’t see that you
    implement UI type editor class to the "table" property. You first need
    to create your own class that derives from UITypeEditor. Then you need
    to use the Editor attribute for that property [2].

    I strongly recommand you to get a copy of :
    Developing Microsoft ASP.NET Server Controls and Components
    By Nikhil Kothari, Vandana Datje


    [1] A class that is associated with a type or a property and provides a
    specialized user interface for editing a property. A UI type editor is
    launched from the property browser and is useful when the simple text
    entry UI provided by the property browser is not adequate for editing a
    property. For example, the color picker drop-down list within the
    property grid that enables a page developer to select a color for the
    BackColor or ForeColor property of a Web control in a WYSIWYG fashion is
    a UI type editor. We'll show you how to implement UI type editors in the
    "UI Type Editors" section in this chapter.

    [2]
    [Editor(typeof(MyStringEditor),
    typeof(UITypeEditor))
    ]
    public override Table Text {
    get {
    ...;
    }
    set {
    ...;
    }
    }


    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  4. #3

    Default Re: Custom Control Table member variable broke



    I have purchased this book last night and begun reading. However, the
    Table UI editor is already built into VS and should be reusable.Every
    sample in the book and online only uses a super custom class as an
    example in which you have to go overide all these methods but this is
    your standard table with no frills just like FontInfo,ImageEditor,URL
    builder and Color. If your test this code it makes a beautiful table and
    does everything it should do. VS automatically chooses the correct
    Editor based on a table and its even reflected in the design view. But
    the code isn't getting serialized when you change the table properties
    only if you change the tables font property. I bought this book solely
    to answer this question and the only thing close to this is writing a
    property for every attribute of a table as shown in the example on page
    220. Any help will be greatly appreciated....



    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Troy Dedmon 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