不知道为什么,但是当为控件更新ajax updatePanel回发它实际上完成页面的完整回发时,它在IE上运行正常但是使用mozilla它会重新加载整个页面。Ajax.net更新面板不工作在Mozilla Firefox上
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Panel ID="userLogin" Visible=false runat=server>
<table>
<tr>
<td colspan="2">
<asp:Label ID="Label27" runat="server" style="font-weight: 700"
Text="Registered Users"></asp:Label>
</td>
<td class="style2">
</td>
<td>
<asp:Label ID="Label30" runat="server" Text="New Users"
style="font-weight: 700"></asp:Label>
</td>
<td class="style7">
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label28" runat="server" Text="Email"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox11" runat="server" Width="160px" TabIndex="1"></asp:TextBox>
</td>
<td class="style2">
</td>
<td>
<asp:Label ID="Label31" runat="server" Text="Email"></asp:Label>
</td>
<td class="style7">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox13" runat="server" AutoPostBack="True"
ontextchanged="TextBox_TextChanged" TabIndex="3" Width="160px"></asp:TextBox>
<asp:Image ID="Image6" runat="server" ImageUrl="~/Classifieds/images/notOk.jpg"
Visible="False" />
<asp:Image ID="Image5" runat="server" ImageUrl="~/Classifieds/images/ok.jpg"
Visible="False" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="registerErrorLabel" runat="server" ForeColor="Red"></asp:Label>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<asp:Image ID="Image4" runat="server"
ImageUrl="~/Classifieds/images/ajax-loader.gif" />
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TextBox13" EventName="TextChanged" />
<asp:AsyncPostBackTrigger ControlID="TextBox15" EventName="TextChanged" />
<asp:AsyncPostBackTrigger ControlID="CheckBox4" EventName="CheckedChanged" />
</Triggers>
</asp:UpdatePanel>
文本框的AutoPostBack是真实的,它只是检查用户是否存在或有效和更新面板内的一个标签上显示一个消息。
这里是一个文本框触发事件背后的代码:
protected void TextBox_TextChanged(object sender, EventArgs e)
{
if (isEmail(TextBox13.Text))
{
if (DB2.alreadyRegistered(TextBox13.Text))
{
registerErrorLabel.Text = "This email has already been registered,<br/>If you forgot your password please <a href='../../../forgot.aspx' target=blank>click here</a> (will open on a new window)";
registerErrorLabel.Visible = true;
Image5.Visible = false;
Image6.Visible = true;
TextBox13.BorderColor = System.Drawing.Color.Red;
}
else
{
registerErrorLabel.Visible = true;
Image5.Visible = true;
Image6.Visible = false;
TextBox13.BorderColor = System.Drawing.Color.Green;
}
}
else {
registerErrorLabel.Text = "Please use a valid email";
Image5.Visible = false;
Image6.Visible = true;
TextBox13.BorderColor = System.Drawing.Color.Red;
}
}
umm更新面板中没有标签?你是在展示其中一幅图像,而不是显示它是否有效? – 2010-01-27 16:37:33
也只是一个建议,但你应该真的有有意义的控制ID,因为这可能会在代码背后变得混乱,并通过使用错误的控件导致一些奇怪的行为。这可能是现在正在发生的事情,但如果没有看到你的代码,很难说清楚。 – 2010-01-27 16:40:32
抱歉,有两列,其中一个用于注册用户,另一个用于新用户(桌子上的两列)忘记包含第二个更新面板,一个在顶部,文本框旁边有一个图像,另一个位于registerErrorLabel的底部(显示错误的标签,如果有的话) – George 2010-01-27 16:45:37