How do I put a user control into a table?

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

  1. #1

    Default How do I put a user control into a table?

    I have a user control that create a product thumbnail and details. I am
    working on aother user control that I will pass some variables like # of
    columns and rows to display these thumbnails. I'm having trouble dynamicly
    adding a new thumbnail control to my table.

    Dim newCell As New TableCell
    Dim newRow As New TableRow
    Dim productThumb As New htmlBlock_ProductThumb ' This is my
    usercontrol

    newCell.Controls.Add(productThumb) ' Not
    sure how to add it to the table cell
    newRow.Cells.Add(newCell)

    FeaturedProducts.Rows.Add(newRow)


    Robin Bonin Guest

  2. Similar Questions and Discussions

    1. user control problem access value from user control to a page
      Thanks a lot for paying attention to my problem , i tell u the problem i have a main form in which i gave a login label that points to a...
    2. Know in user control page_load if an user control event is going to be fired
      Hi all, i have built a user control that shows a map and let the user zoom in, out, usual stuff. Putting this object in a webform the user can...
    3. Dynamic user control in a table.
      I have a user control, htmlBlock_ProductThumb that I would like to add to a dot net table. I'm not sure how to get the output of the usercontrol...
    4. Web user control content doesn't resize in web form table
      Hi Paul: The only suggestion I could give is to wrap the table with a <div> tag, and set the width of that <div> to be 100%. ASP.NET controls...
    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: How do I put a user control into a table?

    Robin,

    When you load a user control it's slightly different than creating a dynamic
    control.

    newCell.Controls.Add(LoadControl([Path to your user control as String])

    And you won't need to create the user control before this so delete the
    line:

    Dim productThumb As New htmlBlock_ProductThumb ' This is my usercontrol

    Sincerely,

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    [url]www.aboutfortunate.com[/url]

    "Out of chaos comes order."
    Nietzche


    "Robin Bonin" <robin@guavatools.com> wrote in message
    news:3FWdnbRIWMP_LaqiU-KYvw@eatel.net...
    > I have a user control that create a product thumbnail and details. I am
    > working on aother user control that I will pass some variables like # of
    > columns and rows to display these thumbnails. I'm having trouble dynamicly
    > adding a new thumbnail control to my table.
    >
    > Dim newCell As New TableCell
    > Dim newRow As New TableRow
    > Dim productThumb As New htmlBlock_ProductThumb ' This is my
    > usercontrol
    >
    > newCell.Controls.Add(productThumb) '
    Not
    > sure how to add it to the table cell
    > newRow.Cells.Add(newCell)
    >
    > FeaturedProducts.Rows.Add(newRow)
    >
    >

    S. Justin Gengo Guest

  4. #3

    Default Re: How do I put a user control into a table?

    Found the answer to my question.
    for reference...

    Dim newCell As New TableCell
    Dim newRow As New TableRow
    Dim productThumb As New Control

    productThumb =
    LoadControl("../userControls/htmlBlock_ProductThumb.ascx")
    CType(productThumb, htmlBlock_ProductThumb).itemSku = "1001A"
    newCell.Controls.Add(productThumb)

    newRow.Cells.Add(newCell)
    FeaturedProducts.Rows.Add(newRow)


    "Robin Bonin" <robin@guavatools.com> wrote in message
    news:556cnasC49bBKqqiXTWJjA@eatel.net...
    > This worked great, I just have one problem.
    > I need to pass atleast one paramater to this control for the item ID to be
    > dsiplayed.
    >
    > I declared the control as follows.
    > productThumb = LoadControl("../userControls/htmlBlock_ProductThumb.ascx")
    >
    > but the public properties are not exposed though the productThumb control.
    I
    > tried passing a variable
    > through the querry string but I got an error. control needs to end with a
    > .ascx.
    >
    >
    >
    > "S. Justin Gengo" <sjgengo@aboutfortunate.com> wrote in message
    > news:%2328pEtBYDHA.416@tk2msftngp13.phx.gbl...
    > > Robin,
    > >
    > > When you load a user control it's slightly different than creating a
    > dynamic
    > > control.
    > >
    > > newCell.Controls.Add(LoadControl([Path to your user control as String])
    > >
    > > And you won't need to create the user control before this so delete the
    > > line:
    > >
    > > Dim productThumb As New htmlBlock_ProductThumb ' This is my
    usercontrol
    > >
    > > Sincerely,
    > >
    > > --
    > > S. Justin Gengo, MCP
    > > Web Developer
    > >
    > > Free code library at:
    > > [url]www.aboutfortunate.com[/url]
    > >
    > > "Out of chaos comes order."
    > > Nietzche
    > >
    > >
    > > "Robin Bonin" <robin@guavatools.com> wrote in message
    > > news:3FWdnbRIWMP_LaqiU-KYvw@eatel.net...
    > > > I have a user control that create a product thumbnail and details. I
    am
    > > > working on aother user control that I will pass some variables like #
    of
    > > > columns and rows to display these thumbnails. I'm having trouble
    > dynamicly
    > > > adding a new thumbnail control to my table.
    > > >
    > > > Dim newCell As New TableCell
    > > > Dim newRow As New TableRow
    > > > Dim productThumb As New htmlBlock_ProductThumb ' This is my
    > > > usercontrol
    > > >
    > > > newCell.Controls.Add(productThumb)
    '
    > > Not
    > > > sure how to add it to the table cell
    > > > newRow.Cells.Add(newCell)
    > > >
    > > > FeaturedProducts.Rows.Add(newRow)
    > > >
    > > >
    > >
    > >
    >
    >

    Robin Bonin 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