日期:2014-05-17  浏览次数:20436 次

如何在DetailsView模版字段里使用ScriptManager??
我想在DetailsView中加一个时时刷新时间的Label
代码如下:
                        <asp:ScriptManager ID="ScriptManager1" runat="server">
                        </asp:ScriptManager>
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                                <asp:Label ID="LabelTime" runat="server" Text='<%# DateTime.Now.ToLongTimeString() %>'></asp:Label>
                                <asp:Timer ID="Timer1" runat="server" Interval="1000"></asp:Timer>
                            </ContentTemplate>
                        </asp:UpdatePanel>

但是报错说【可能无法在 PreRender 之前注册脚本控件。 】
我就惆怅了...
如果把ScriptManager控件放在模版字段的外面,可以正常运行,但是时间Label不会即时刷新...
求破!!!

------解决方案--------------------
ScriptManager放在外面,用UpdatePanel 将DetailsView套起来就可以了。
------解决方案--------------------
引用:
ScriptManager放在外面,用UpdatePanel 将DetailsView套起来就可以了。

楼上正解,必须把ScriptManager放在最前面。