简体   繁体   English

为什么所有内容都在更新面板的内容模板内对齐?

[英]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 如果我在更新计时器启动之前在2个标签中写入虚拟文本,则一个按预期出现在右侧,另一个出现在左侧,但是,当updateTimer进入图片时,两个文本都出现在左侧,彼此粘在一起

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"></asp:LinkButton>
                                                        </td>
                                                    </ContentTemplate>
                                                </asp:UpdatePanel>
                                            </tr>
                                        </table>

The TimedPanel is rendering as a span , like this: TimedPanel呈现为span ,如下所示:

<span id="TimedPanel">
   <span id="userNameLabel">label</span>
   <a id="userWebsiteLabel" href="javascript:__doPostBack('userWebsiteLabel','')">linkbutton</a>
</span>

Change your ContentTemplate to: 将您的ContentTemplate更改为:

<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: 并添加一些CSS以将LinkButton右对齐:

<style type="text/css">
#TimedPanel a {float: right;}
</style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM