我有一个有两个按钮的 asp.net 网页。它们位于两个不同的update panels
并更新两个不同的文本框。
我首先单击第一个按钮,等待 5 秒,然后单击第二个按钮。结果,我期望两个文本框都有价值——但只有一个有。
问题
- 为什么第一个文本框没有更新?当我单击第二个按钮时,第一个请求是否被中止?任何msdn参考?
- 即使我们在第一个完成之前单击第二个按钮,有什么方法可以在两个文本框中获取值?
标记
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxTest.aspx.cs" Inherits="MyUI.AjaxTest"
EnableSessionState="False" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="scrSubscribers" runat="server" />
<div>
<div style="border-style: solid; border-color: #00FFFF">
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Always">
<ContentTemplate>
<div class="firstTextBox">
<asp:TextBox ID="txtAssociateName" runat="server" Width="150px" MaxLength="81" TabIndex="1"></asp:TextBox>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode="Always">
<ContentTemplate>
<div class="firstTextBox">
<asp:TextBox ID="txtDepartment" runat="server" Width="150px" MaxLength="81" TabIndex="1"></asp:TextBox>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<br />
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnLoad="UpdatePanel1_Load" UpdateMode="Conditional">
<ContentTemplate>
<div id="searchValues" class="searchValuesDiv">
<div id="searchLine1" class="searchLine">
</div>
<div id="searchLine5" class="searchLine">
<div class="btnSearchDiv">
<asp:Button ID="btnFirst" class="btnSearch" runat="server" OnClick="SearchSubscribersClick"
Text="FirstButton" ValidationGroup="Search" />
<asp:TextBox ID="txtFirstDate" runat="server" Width="150px" MaxLength="81" TabIndex="1"></asp:TextBox>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<br />
<asp:UpdatePanel ID="UpdatePanel2" runat="server" OnLoad="UpdatePanel1_Load" UpdateMode="Conditional">
<ContentTemplate>
<div id="Div1" class="searchValuesDiv">
<div id="Div3" class="searchLine">
<div class="btnSearchDiv">
<asp:Button ID="btnSecond" class="btnSearch" runat="server" OnClick="SecondClick"
Text="SecondButton" ValidationGroup="Search" />
<asp:TextBox ID="txtSecondDate" runat="server" Width="150px" MaxLength="81" TabIndex="1"></asp:TextBox>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:HiddenField ID="hdnSearchClickStatus" runat="server" Value="Blank Value" />
</div>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="Scripts/ExpandableSearchResultScript.js" type="text/javascript"></script>
</form>
</body>
</html>
代码背后
protected void SearchSubscribersClick(object sender, EventArgs e)
{
Thread.Sleep(10000);
txtAssociateName.Text = "A_"+ DateTime.Now.ToString();
}
protected void SecondClick(object sender, EventArgs e)
{
Thread.Sleep(10000);
txtDepartment.Text = "B_" + DateTime.Now.ToString();
}
结果