日期:2014-05-18  浏览次数:20835 次

问个关于AJAX Extensions中Timer控件的问题
在下用AJAX Extensions组中的Timer控件在网页上做了个时钟(Timer放在UpdatePanel里)每秒刷新Label控件的时间显示(Timer、Label在UpdatePanel里,UpdatePanel控件放在页面的MasterPage里)。

运行结果是:

时间显示满足要求,但出现问题:刷新后页面的标题会变为“无标题页”。
PS:直接从浏览器查看页面的源代码title仍然是想要的标题,只是实际显示时会变为“无标题页”。

目前有一替代方案:
在Page_Load时读取服务器时间填入页面控件,然后在客户端用js的setTimeout函数刷控件显示。
在下还想问的是有没有哪位大神知道出现上述问题的原因,并能给出Ajax的解决方案。毕竟用js刷新控件的方案是存在一定漏洞的。

------解决方案--------------------
做了一下不会改变标题啊,我的代码:
标题是:aaaaaa
HTML code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>aaaaaa</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                <asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick">
                </asp:Timer>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>