Привет,
У меня есть веб-страница asp.net с modalpopupextender внутри панели обновления. Когда я нажимаю Ok во всплывающем окне, я могу получить значения текстового поля из всплывающего окна очень хорошо, но 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>
, , , ТОГДА ЗДЕСЬ. , .
Этот модальный popupextender здесь был искажен. Я не могу получить stackoverflow, чтобы показать это правильно.
Это показывает свойства здесь, хотя.
"
BackgroundCssClass = "modalBackground"
DropShadow = "истина"
OkControlID = "btnEditOk"
CancelControlID = "btnEditCancel" Animations = "">
</ContentTemplate>
</asp:UpdatePanel>
=========================================
Серверная сторона
защищенный void btnEditOk_Click (отправитель объекта, EventArgs e)
{
IssueDAO issueDAO = новый IssueDAO ();
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;
}