Why all contents are aligned left within a content template in an update panel?
If I write dummy text in the 2 labels before the update timer starts, one appears at the right and the other appears at the left as expected However, when the updateTimer gets into picture both texts appear on the left stuck to each other
here's the code
<table width="100%" border="0" cellspacing="7" cellpadding="0">
<tr>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer runat="server" ID="UpdateTimer" Interval="5000" OnTick="UpdateTimer_Tick" />
<asp:UpdatePanel runat="server" ID="TimedPanel" UpdateMode="Conditional" RenderMode="Inline">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="UpdateTimer" EventName="Tick" />
</Triggers>
<ContentTemplate>
<td align="left">
<asp:Label ID="userNameLabel" runat="server"></asp:Label>
</td>
<td align="right">
<asp:LinkButton ID="userWebsiteLabel" runat="server"&g开发者_JAVA技巧t;</asp:LinkButton>
</td>
</ContentTemplate>
</asp:UpdatePanel>
</tr>
</table>
The TimedPanel is rendering as a span
, like this:
<span id="TimedPanel">
<span id="userNameLabel">label</span>
<a id="userWebsiteLabel" href="javascript:__doPostBack('userWebsiteLabel','')">linkbutton</a>
</span>
Change your ContentTemplate
to:
<ContentTemplate>
<asp:Label ID="userNameLabel" runat="server" Text="label" />
<asp:LinkButton ID="userWebsiteLabel" runat="server" Text="linkbutton" />
</ContentTemplate>
And add some CSS to align the LinkButton
to the right:
<style type="text/css">
#TimedPanel a {float: right;}
</style>
精彩评论