問候改變,DropDownList的值不是的UpdatePanel和ModalPopupExtender
我有一個modalpopupextender一個asp.net網頁一個UpdatePanel內。當我在彈出框中單擊「確定」時,我可以從彈出窗口中獲取文本框值,但DropDownLists具有舊/默認值,而不是我爲它們選擇的新值。
彈出窗口中的所有控件都設置爲enableviewstate = true,autopostback = false(我只是想點擊ok按鈕而不是每次更改彈出窗口的值時, 。
這裏是相關的代碼。
==========================
客戶端
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="EditIssuePanel" runat="server" CssClass="modalPopup" Style="display:block;" >
<table style="width:500px;">
<tr style="height:50px;">
<td colspan="2" align="center">
<asp:Label ID="lblEditIssueHeader" runat="server" Text="Edit Issue"></asp:Label>
</td>
</tr>
<tr style="height:30px;">
<td class="labelscolumn">
<asp:Label ID="lblIssueName" runat="server" Text="Name:"></asp:Label>
</td>
<td class="datacolumn">
<asp:TextBox ID="txtName" runat="server" Width="250px" MaxLength="50"></asp:TextBox>
</td>
</tr>
<tr style="height:30px;">
<td class="labelscolumn">
<asp:Label ID="lblDescription" runat="server" Text="Description:"></asp:Label>
</td>
<td class="datacolumn">
<asp:TextBox ID="txtDescription" runat="server" Width="250px" MaxLength="1000"></asp:TextBox>
</td>
</tr>
<tr style="height:30px;">
<td class="labelscolumn">
<asp:Label ID="lblType" runat="server" Text="Type:"></asp:Label>
</td>
<td class="datacolumn">
<asp:DropDownList ID="ddlType" runat="server">
<asp:ListItem Selected="True" Value="B">Bug</asp:ListItem>
<asp:ListItem Value="R">Request</asp:ListItem>
<asp:ListItem Value="O">Other</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr style="height:30px;">
<td class="labelscolumn">
<asp:Label ID="lblStatus" runat="server" Text="Status:"></asp:Label>
</td>
<td class="datacolumn">
<asp:DropDownList ID="ddlStatus" runat="server">
<asp:ListItem Selected="True" Value="L">Logged</asp:ListItem>
<asp:ListItem Value="I">In Process</asp:ListItem>
<asp:ListItem Value="C">Complete</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr style="height:30px;">
<td class="labelscolumn">
<asp:Label ID="lblPriority" runat="server" Text="Priority:"></asp:Label>
</td>
<td class="datacolumn">
<asp:DropDownList ID="ddlPriority" runat="server" EnableViewState="true" AutoPostBack="false">
<asp:ListItem Selected="True" Value="L">Low</asp:ListItem>
<asp:ListItem Value="M">Medium</asp:ListItem>
<asp:ListItem Value="H">High</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr style="height:30px">
<td class="labelscolumn">Logger</td>
<td class="datacolumn">
<asp:Label ID="lblEnteredByClientUserID" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr style="height:30px;">
<td class="labelscolumn">
<asp:Label ID="lblDateResolutionRequested" runat="server" Text="Requested Complete Date:"></asp:Label>
</td>
<td class="datacolumn">
<igsch:WebDateChooser ID="wdcRequestCompleteDate" runat="server">
</igsch:WebDateChooser>
</td>
</tr>
<tr style="height:30px">
<td class="labelscolumn">Logged Date</td>
<td class="datacolumn">
<asp:Label ID="lblLoggedDate" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr style="height:30px">
<td class="labelscolumn">In Process Date</td>
<td class="datacolumn">
<asp:Label ID="lblInProcessDate" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr style="height:30px">
<td class="labelscolumn">Resolved Date</td>
<td class="datacolumn">
<asp:Label ID="lblResolvedDate" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr style="height:30px;">
<td class="labelscolumn" valign="top">
<asp:Label ID="lblEmailCCList" runat="server" Text="Email CC:"></asp:Label>
</td>
<td class="datacolumn">
<asp:TextBox ID="txtEmailCCList" runat="server" MaxLength="2000" Rows="0"
TextMode="MultiLine" Height="83px" Width="250px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblIssueID" runat="server" Text="" Visible="false"></asp:Label>
<asp:Label ID="lblClientID" runat="server" Text="" Visible="false"></asp:Label>
</td>
<td align="right">
<asp:Button ID="btnEditOk" runat="server" Text="Ok" onclick="btnEditOk_Click"/>
<asp:Button
ID="btnEditCancel" runat="server" Text="Cancel" onclick="btnEditCancel_Click" />
</td>
</tr>
</table>
</asp:Panel>
。 。 。那裏有一個WEBGRID在這裏。 。 。
這種模式的popupextender在這裏受到了重創。我不能得到stackoverflow來顯示它的權利。 雖然它顯示了這裏的屬性。 「 BackgroundCssClass =」 modalBackground」 陰影效果= 「真」 OkControlID = 「btnEditOk」 CancelControlID = 「btnEditCancel」 動畫= 「」>
</ContentTemplate>
</asp:UpdatePanel>
=========== ==============================
服務器端
保護無效btnEditOk_Click(對象發件人,EventArgs的) IssueDAO issueDAO = new Iss ueDAO();
string client = "Eichleay";
string name = null;
string description = null;
string type = null;
string status = null;
DateTime? resolvedDate = null;
string enteredByClientUserName = User.Identity.Name.ToString();
DateTime? loggedDate = DateTime.Now;
DateTime? inProcessDate = null;
DateTime? completeDate = null;
DateTime? requestCompleteDate = null;
string priority = null;
int? prioritySort = null;
string emailCCList = null;
name = txtName.Text.Substring(txtName.Text.Length > 0 ? 1 : 0, (txtName.Text.Length > 0 ? txtName.Text.Length : 1) - 1);
description = txtDescription.Text.Substring(txtDescription.Text.Length > 0 ? 1 : 0, (txtDescription.Text.Length == 0 ? 1 : txtDescription.Text.Length) - 1);
type = ddlType.SelectedValue;
status = ddlStatus.SelectedValue;
resolvedDate = string.IsNullOrEmpty(lblResolvedDate.Text) == true ? null : new Nullable<DateTime>(Convert.ToDateTime(lblResolvedDate.Text));
inProcessDate = string.IsNullOrEmpty(lblInProcessDate.Text) == true ? null : new Nullable<DateTime>(Convert.ToDateTime(lblInProcessDate.Text));
completeDate = string.IsNullOrEmpty(lblResolvedDate.Text) == true ? null : new Nullable<DateTime>(Convert.ToDateTime(lblResolvedDate.Text));
requestCompleteDate = wdcRequestCompleteDate.Value == null ? null : string.IsNullOrEmpty(wdcRequestCompleteDate.Value.ToString()) == true ? null : new Nullable<DateTime>(Convert.ToDateTime(wdcRequestCompleteDate.Value.ToString()));
priority = ddlPriority.SelectedValue;
emailCCList = txtEmailCCList.Text.Substring(txtEmailCCList.Text.Length > 0 ? 1 : 0, (txtEmailCCList.Text.Length > 0 ? txtEmailCCList.Text.Length : 1) - 1);
if (lblEditIssueHeader.Text.Substring(0, 3) == "New")
{
issueDAO.InsertIssue(client,
name,
description,
type,
status,
resolvedDate,
enteredByClientUserName,
loggedDate,
inProcessDate,
completeDate,
requestCompleteDate,
priority,
prioritySort,
emailCCList);
}
else
{
Issue issue = new Issue(Convert.ToInt32(lblIssueID.Text),
lblClientID.Text,
txtName.Text.Substring(txtName.Text.Length > 0 ? 1 : 0, (txtName.Text.Length > 0 ? txtName.Text.Length : 1) - 1),
txtDescription.Text.Substring(txtDescription.Text.Length > 0 ? 1 : 0, (txtDescription.Text.Length == 0 ? 1 : txtDescription.Text.Length) - 1),
ddlType.SelectedValue,
ddlStatus.SelectedValue,
string.IsNullOrEmpty(lblResolvedDate.Text) == true ? null : new Nullable<DateTime>(Convert.ToDateTime(lblResolvedDate.Text)),
lblEnteredByClientUserID.Text,
string.IsNullOrEmpty(lblLoggedDate.Text) == true ? null : new Nullable<DateTime>(Convert.ToDateTime(lblLoggedDate.Text)),
string.IsNullOrEmpty(lblInProcessDate.Text) == true ? null : new Nullable<DateTime>(Convert.ToDateTime(lblInProcessDate.Text)),
string.IsNullOrEmpty(lblResolvedDate.Text) == true ? null : new Nullable<DateTime>(Convert.ToDateTime(lblResolvedDate.Text)),
string.IsNullOrEmpty(wdcRequestCompleteDate.Value.ToString()) == true ? null : new Nullable<DateTime>(Convert.ToDateTime(wdcRequestCompleteDate.Value.ToString())),
ddlPriority.SelectedValue,
null,
txtEmailCCList.Text.Substring(txtEmailCCList.Text.Length > 0 ? 1 : 0, (txtEmailCCList.Text.Length > 0 ? txtEmailCCList.Text.Length : 1) - 1));
issueDAO.UpdateIssue(issue);
}
// wdgIssues.ClearDataSource();
// UpdatePanel1.Update();
lblIssueID.Text = null;
lblClientID.Text = null;
txtName.Text = null;
txtDescription.Text = null;
ddlType.SelectedValue = null;
ddlStatus.SelectedValue = null;
lblLoggedDate.Text = null;
lblInProcessDate.Text = null;
lblResolvedDate.Text = null;
wdcRequestCompleteDate.Value = null;
ddlPriority.SelectedValue = null;
txtEmailCCList.Text = null;
}
我遇到了同樣的問題,對我來說,我在ModalPopupExtender中顯示了代碼隱藏中的.Show()方法,該方法是通過在GridView中單擊按鈕來調用的。它的定義似乎是導致它的原因;例如,如果您嘗試在Page_Load上打開模式彈出窗口,它就會起作用。我會繼續調查,因爲我也需要這項工作,如果我能做到,請留下一個答案。如果你修復它,請保持更新。 – bgs264 2010-04-13 09:13:33