Combining Two Controls, best way?

Discussion in 'ASP .Net Building Controls' started by Andrew Backer, Jul 14, 2005.

  1. I have a working date picker, and I want to combine it at the control
    level with a textbox and validator, so we can use
    <my:datepickertextboxthingy/>

    What is the best way to go about this? I am most concerned with access
    to the textbox's properties, since this will function mostly as a
    textbox with a mostly-inert object attached to it.

    Right now I have subclassed TextBox, and am attempting to somehow
    attach the other control to it so they both get rendered. In the end I
    think I would like to be able to wrap them in more html (tables, span,
    div, etc), so I think I will need a little more control. In the end I
    need to be here :

    <my:textbox CssClass="Fun" Columns="10" ..more textbox props.../>

    Where should I instantiate the addtional controls? How should I handle
    prerender (the date picker needs it)? What should I do in Render() to
    make this happen...

    I guess I am really trying to avoid writing properties that wrap *all*
    of the textbox properties. Any good way to do this?

    TIA,
    - Andrew Backer
     
    Andrew Backer, Jul 14, 2005
    #1
    1. Advertising

  2. I suggest you create a composite control.
    Here are the details:
    http://SteveOrr.net/articles/ComboBox.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "Andrew Backer" <> wrote in message
    news:...
    >I have a working date picker, and I want to combine it at the control
    > level with a textbox and validator, so we can use
    > <my:datepickertextboxthingy/>
    >
    > What is the best way to go about this? I am most concerned with access
    > to the textbox's properties, since this will function mostly as a
    > textbox with a mostly-inert object attached to it.
    >
    > Right now I have subclassed TextBox, and am attempting to somehow
    > attach the other control to it so they both get rendered. In the end I
    > think I would like to be able to wrap them in more html (tables, span,
    > div, etc), so I think I will need a little more control. In the end I
    > need to be here :
    >
    > <my:textbox CssClass="Fun" Columns="10" ..more textbox props.../>
    >
    > Where should I instantiate the addtional controls? How should I handle
    > prerender (the date picker needs it)? What should I do in Render() to
    > make this happen...
    >
    > I guess I am really trying to avoid writing properties that wrap *all*
    > of the textbox properties. Any good way to do this?
    >
    > TIA,
    > - Andrew Backer
    >
     
    Steve C. Orr [MVP, MCSD], Jul 14, 2005
    #2
    1. Advertising

  3. So I have to go the composite way, eh? Oh well...

    Are we sure that there is no way to inherit TextBox, thereby gaining
    all it's fancy properties and methods, and *then* tacking on the
    datepicker/checkbox/etc that I need?

    Im going to go the composite way for now, but the other way would be
    sooooooo nifty :)

    Thanks for the article,
    - Andrew Backer
     
    Andrew Backer, Jul 15, 2005
    #3
    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. williams
    Replies:
    1
    Views:
    914
  2. Winterminute

    Combining Two Data Sources for one Data List

    Winterminute, Dec 3, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    852
    Winterminute
    Dec 3, 2003
  3. chris

    combining two documents

    chris, Jul 31, 2003, in forum: XML
    Replies:
    2
    Views:
    460
    Dimitre Novatchev
    Jul 31, 2003
  4. jm
    Replies:
    0
    Views:
    275
  5. novus
    Replies:
    9
    Views:
    253
    last component
    Dec 14, 2005
Loading...

Share This Page