AJAX回发中的标题标签已清除 [英] Title Tag Is Cleared on AJAX Postback
问题描述
我创建了这个简单的ASP.Net页面:
I created this simple ASP.Net page:
<%@ Page %>
<html>
<head runat="server">
<title>
<asp:Literal runat="server" Text="Hello" />
</title>
</head>
<body>
<form runat="server">
<asp:ScriptManager runat="server" />
<asp:UpdatePanel runat="server" ID="Whatev">
<ContentTemplate>
<asp:Button runat="server" Text="AJAX Postback" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
当我单击按钮时,浏览器窗口(IE8)中显示的标题将被删除.选项卡中显示的标题是两个正方形块(也许换行符渲染失败).但是,如果我将标题的所有内容都放在一行上(在下面的代码段中突出显示),则单击按钮时标题不会更改:
When I click the button, the title shown in the browser window (IE8) is erased. The title shown in the tab is two square blocks (perhaps a failed rendering of newline characters). However, if I put everything for the title on one line (highlighted in the code snippet below), the title does not change when I click the button:
<%@ Page %>
<html>
<head runat="server">
<big><title><asp:Literal runat="server" Text="Hello" /></title></big>
</head>
<body>
<form runat="server">
<asp:ScriptManager runat="server" />
<asp:UpdatePanel runat="server" ID="Whatev">
<ContentTemplate>
<asp:Button runat="server" Text="AJAX Postback" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
我不知道为什么更新面板中的回发会导致标题更改.而且我不知道为什么将所有内容放在一条线上就能解决问题.有任何想法吗?
I have no idea why a postback in an update panel would cause the title to change. And I have no idea why putting everything on one line fixes it. Any ideas?
推荐答案
您可以尝试在其中放置另一个服务器控件,看看奇怪的行为是否消失了.
读完您的问题后,我正在看一些讨论,并 ^ ]听起来很有趣.
如果放置另一个控件有效,则内部执行UpdatePanels的方式有所不同.奇怪的行为是一种罕见的行为(一个服务器控件和动态页面标题,标题不在一行中). MS可能以其他方式使用了该方案.请更新您的发现.我现在没有ASP.NET环境,否则我会尝试自己的.
Can you try and place one more server control in it and see if the odd behaviour goes away.
After reading your question, I was looking at few discussions and this one [^]sounds interesting.
If placing another control works then there is something in the way UpdatePanels are executed internally. The odd behavior is a rare one (one server control and dynamic Page title with title not in one line). Might be MS used that scenario in some other way. Do update your findings. I don''t have an ASP.NET environment right now with me or else would had tried my self.
这篇关于AJAX回发中的标题标签已清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!