Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Custom Controls

Custom Controls

Scheduled Pinned Locked Moved ASP.NET
htmlsysadminsalesquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Luke Murray
    wrote on last edited by
    #1

    Hi, I'm building a customer control. Which I want to have another custom control in it. So I declare the tag like: <cc:Control1 runat="server" id="control1"> <Control2 runat="server" Width="100px"> <cc:Control2Item Text="Do This"/> <cc:Control2Item Text="Do That"/> </Control2> <Columns> ... </Columns> </cc:Control1> Control1 has a property called Control2 which is of type Control2 Though this doesn't render the Control2 html. What do I need to do to have the parent control render the child? Is there a good article somewhere? I have looked a little but still no luck. I have tried things with [ParseChildren(true, "Control2")] in the Control1 code, but then this gives errors and the Control2Item types. Really not sure what i'm doing wrong, kinda new to custom controls. Thanks for any info. Luke

    M L 2 Replies Last reply
    0
    • L Luke Murray

      Hi, I'm building a customer control. Which I want to have another custom control in it. So I declare the tag like: <cc:Control1 runat="server" id="control1"> <Control2 runat="server" Width="100px"> <cc:Control2Item Text="Do This"/> <cc:Control2Item Text="Do That"/> </Control2> <Columns> ... </Columns> </cc:Control1> Control1 has a property called Control2 which is of type Control2 Though this doesn't render the Control2 html. What do I need to do to have the parent control render the child? Is there a good article somewhere? I have looked a little but still no luck. I have tried things with [ParseChildren(true, "Control2")] in the Control1 code, but then this gives errors and the Control2Item types. Really not sure what i'm doing wrong, kinda new to custom controls. Thanks for any info. Luke

      L Offline
      L Offline
      Luke Murray
      wrote on last edited by
      #2

      Ok I can now get the child control rendering, I had to call it's RenderControl... Pretty simple. My issue is now that Control1 inherites from a DataGrid and I want to add a column everytime to the end. I was doing this in the OnInit() method and it was working. until now, because the new column need a reference to the controllist of Control2 which has not been created yet. So if I move the code to OnPrerender, or Render the code does not fial because the Control2 controls has been created, but so have the Control1 controls so the new column does not show up. Any ideas?

      1 Reply Last reply
      0
      • L Luke Murray

        Hi, I'm building a customer control. Which I want to have another custom control in it. So I declare the tag like: <cc:Control1 runat="server" id="control1"> <Control2 runat="server" Width="100px"> <cc:Control2Item Text="Do This"/> <cc:Control2Item Text="Do That"/> </Control2> <Columns> ... </Columns> </cc:Control1> Control1 has a property called Control2 which is of type Control2 Though this doesn't render the Control2 html. What do I need to do to have the parent control render the child? Is there a good article somewhere? I have looked a little but still no luck. I have tried things with [ParseChildren(true, "Control2")] in the Control1 code, but then this gives errors and the Control2Item types. Really not sure what i'm doing wrong, kinda new to custom controls. Thanks for any info. Luke

        M Offline
        M Offline
        minhpc_bk
        wrote on last edited by
        #3

        Hi there, You might want to check out some good articles in MSDN to see how to develop a templated custom control: Building Templated Custom ASP.NET Server Controls[^] Building DataBound Templated Custom ASP.NET Server Controls[^] Developing ASP.NET Server Controls[^] If you want to look for a book, I recommend this one: Developing Microsoft® ASP.NET Server Controls and Components [^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups