views:

45

answers:

1

Hi,

I have a ASP UserControl that looks like this:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs"
    Inherits="WebApplication2.WebUserControl1" %>
    <table>
        <tr>
            <td>
                <asp:Image ID="Image1" runat="server" Width="100" Height="100" ImageUrl="~/Logo.png" />
            </td>
        </tr>
        <tr>
            <td>
                Test
            </td>
        </tr>
    </table>

Additionally I have a asp page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>
<%@ Register Tagprefix="uc1" Tagname="uc1" Src=".\WebUserControl1.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <span>
        <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
    </span>
    </form>
</body>
</html>

When I add sveral the usercontrols at runtime using

 protected void Page_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 5; i++)
            {
                var test = LoadControl(@"~\WebUserControl1.ascx");
                PlaceHolder1.Controls.Add(test);    
            }

        }

they are added to the placeholder but aligned one below the other. I'd like them to be placed one next to another. Is this possible and if yes, how?

Regards

+1  A: 

Make your table float:right, e.g:

<table style="float:left">
    ...
</table>

Or maybe an even cleaner solution: put a div around the contents of your user control and set the div to float:right:

<%@ Control Language="C#" ... %>
<div style="float:right">  
<table>
  ...
</table>
</div>

BTW: if the page is not wide enough to display all tables on one row, then they will be wrapped to a new line with this solution.

M4N
+1 but you and I know all of this sucks.
BC