views:

153

answers:

2

I found this article on how to manipulate the rendering sequence of asp.net controls.: http://weblogs.asp.net/infinitiesloop/archive/2007/09/07/rendering-asp-net-controls-out-of-order.aspx I placed some placeholders on the page to encapsulate the controls i want to move around. The problem is, that RenderChildren does render the controls without the html i placed into the placeholder like this:

<asp:PlaceHolder id="phOneToMove" Runat="server" Visible="true">
<tr>
<td><asp:Literal id="label1" Runat="server">Caption</asp:Literal></td>
<td>
<asp:TextBox ID="textbox1" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="validator1" Enabled="true" ControlToValidate="textbox1" runat="server" EnableClientScript="False" ErrorMessage="error"></asp:RequiredFieldValidator>
</td>
</tr>
</asp:PlaceHolder>

The controls are rendered without the tr and td around. How can I handle this? All I want is to change the order of the placeholders like in this example phOneToMove.

Note: I am running on asp.net 2.0.

A: 

Hey,

HTML tags are stored as controls of tyep Literal or LiteralControl, so however th elogic works has to check for controls of that type to ensure they get to their destination too.

Brian
A: 

I found the solution. My problem was, that the literal html elements (not LiteralControls) were not in the Controls property of my usercontrol. I did not know why. So I started to debug the .net Framework code itself ans setup a project with no overhead.

Short: I had code in the ascx file itself like <b><%= myOutputVariable %></b>. This causes asp to not put the literal content of a file into the controls collection. After I removed this code it worked like expected.

Uwe