gpt4 book ai didi

c# - 如何在更新面板中打开模态弹出窗口?

转载 作者:行者123 更新时间:2023-11-30 17:18:23 24 4
gpt4 key购买 nike

我有下一个要求:显示多个选项的 DropDownList选择不同的客户,一旦我选择不同的客户并单击下拉列表下方网格中的按钮 应该显示我选择的那些客户的报价,并且如果我点击一个特定的列,应该打开一个弹出窗口显示详细信息该报价。

有不同的场景:

1.- 如果我使用更新面板并在其中放置下拉列表和网格,当我在该特定列中单击时弹出不起作用。

2.- 如果我不使用更新面板,一切都很好,除了刷新网页。

3.- 如果我在选择下拉列表中的某些内容之前用数据加载网格,弹出窗口会一直工作,直到我在下拉列表中选择某些内容,这就是如果下拉列表触发的事件以某种方式影响网格或弹出窗口,并且这里的一切都在更新面板内。

¿你对我有什么建议?

我有网页的下一个代码:

<div id="contentMain">
<asp:UpdatePanel ID="updPanel" runat="server">
<ContentTemplate>
<div style="margin-left: 190px; margin-bottom: -20px;">
<asp:LinkButton runat="server" ID="LinkButton1" title="Seleccionar Clientes" OnClientClick="refrescarGrid() return false;">
<span class="btnAceptar"></span>
</asp:LinkButton>
</div>
<table align="center">
<tr style="text-align: center">
<td class="labelTitle" style="background-color: #9AA8B3; border-radius: 3px;" colspan="1">
Seleccionar Clientes
</td>
</tr>
<tr>
<td style="font-size: 12px">
<cdis:ucDropDownListMultiple ID="ddlClients2" Requerido="false" LabelText="Clientes:"
runat="server" TextboxClassError="listaMultipleError chosen-choices" ContainerClass="ucTextbox"
TextboxClassNormal="chosen-choices" InputClassError="listaMultipleErrorInput"
InputClassNormal="chosen-choices" OpcionAgregar="false" ValidationGroup="vlg1"
Width="300px" MaxSelected="20" AutoPostBack="false" />
</td>
</tr>
</table>
<div style="">
<asp:LinkButton runat="server" ID="LinkButton2" title="Seleccionar Cotizaciones"
OnClick="btnGetSelectedQuotations">
<span class="btnAceptar"></span>
</asp:LinkButton>
</div>
<asp:ImageButton ID="btnSession" ImageUrl="" runat="server" OnClick="btnSession_Click"
Style="display: none;" />
<div class="subSection" align="center">
<table align="center">
<tr style="text-align: center">
<td class="labelTitle" style="background-color: #9AA8B3; border-radius: 3px;" colspan="1">
Cotizaciones Iniciales por Autorizar
</td>
</tr>
<tr>
<td>
<asp:ImageButton ID="ImageButton1" ImageUrl="" runat="server" OnClick="btnSession_Click"
Style="display: none;" />
</td>
</tr>
</table>
</div>
<div align="center">
<cc1:Grid ID="grdCatalogo" runat="server" AllowAddingRecords="false" Serialize="false"
ShowMultiPageGroupsInfo="false" AllowFiltering="false" AllowSorting="true" AllowGrouping="False"
AutoGenerateColumns="false" AllowPageSizeSelection="false" AllowColumnReordering="true"
AllowPaging="false" Width="100%" Height="100%" AllowRecordSelection="false" ShowFooter="false"
FolderLocalization="/Localization" Language="es" OnDataSourceNeeded="grdCatalogo_DataSourceNeeded">
<ExportingSettings ExportAllPages="true" ExportGroupHeader="true" ColumnsToExport="" />
<PagingSettings ShowRecordsCount="false" />
<ScrollingSettings NumberOfFixedColumns="0" FixedColumnsPosition="Left" />
<ClientSideEvents OnClientCallback="loadGridScripts" ExposeSender="true" />
<Columns>
<cc1:Column DataField="DeseasAutorizar" HeaderText=" Desea Autorizar" ItemStyle-Wrap="false"
Width="109px" Wrap="true" HeaderAlign="center" Align="center">
<TemplateSettings TemplateId="tplActionCheck" />
</cc1:Column>
<cc1:Column HeaderText="Código" DataField="tQuotationClientCode" Wrap="true" HeaderAlign="center"
Width="100px">
</cc1:Column>
<cc1:Column HeaderText="Nombre" DataField="tQuotationClientName" Wrap="true" HeaderAlign="center"
Width="248px">
</cc1:Column>
<cc1:Column HeaderText="Número de Cotización" DataField="tQuotationQuotationNumber"
Wrap="true" HeaderAlign="center" Width="120px">
<TemplateSettings TemplateId="tplIndividualQuotations" />
</cc1:Column>
<cc1:Column HeaderText="Número de Solicitud" DataField="tQuotationRequestNumber"
Wrap="true" HeaderAlign="center" Width="120px">
<TemplateSettings TemplateId="tplIndividualRequest" />
</cc1:Column>
<cc1:Column HeaderText="Tipo de Trabajo" DataField="tQuotationWorkType" Wrap="true"
Width="250px" HeaderAlign="center">
</cc1:Column>
<cc1:Column HeaderText="Código Producto del Cliente" DataField="tQuotationClientProductCode"
Wrap="true" Width="153px" HeaderAlign="center">
</cc1:Column>
<cc1:Column HeaderText="Nombre del Trabajo" DataField="tQuotationWorkName" Wrap="true"
Width="240px" HeaderAlign="center">
</cc1:Column>
<cc1:Column HeaderText="" DataField="tQuotationQuotationId" Visible="false">
</cc1:Column>
<cc1:Column HeaderText="" DataField="tQuotationRequestId" Visible="false">
</cc1:Column>
</Columns>
<Templates>
<cc1:GridTemplate runat="server" ID="tplActionCheck">
<Template>
<asp:CheckBox runat="server" ID="chkClientImp" EnableViewState="true" />
</Template>
</cc1:GridTemplate>
<cc1:GridTemplate runat="server" ID="tplIndividualRequest">
<Template>
<a class='modal' href='<%# "catIndividualRequest.aspx?pRequestId=" + 1+ "&pTmp=1"%>'
title="Actualizar Usuario">
<asp:Label ID="Label1" Text='<%#Container.DataItem["tQuotationRequestNumber"]%>'
runat="server" />
</a>
</Template>
</cc1:GridTemplate>
<cc1:GridTemplate runat="server" ID="tplIndividualQuotations">
<Template>
<a class='modal' href='<%# "catIndividualQuotation.aspx?pQuotationId=" + Container.DataItem["tQuotationQuotationId"] + "&pTmp=1"%>'
title="Actualizar Usuario">
<asp:Label ID="Label1" Text='<%#Container.DataItem["tQuotationQuotationNumber"]%>'
runat="server" />
</a>
</Template>
</cc1:GridTemplate>
</Templates>
</cc1:Grid>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>

代码隐藏:

protected void grdCatalogo_DataSourceNeeded(object sender, GridDataSourceNeededEventArgs e)
{
int count = 0;
if (grdCatalogo.Rows != null)
{
foreach (GridRow row in grdCatalogo.Rows)
{
GridDataControlFieldCell cell = row.Cells[0] as GridDataControlFieldCell;
if (cell != null)
{
CheckBox asignar = cell.FindControl("chkClientImp") as CheckBox;

if (asignar.Checked)
{
DiccionarioAsignar.Add(count, asignar.Checked);
}
}
count++;
}
}

try
{

List<object> lst = new List<object>();
if (ddlClients2.GetSelectedItems().Count > 0)
{
foreach (System.Web.UI.WebControls.ListItem li in ddlClients2.Items)
{
if (li.Selected == true)
{
foreach (object obj in QuotationBLL.Get_QuotationInfoCatalogById(Convert.ToInt32(li.Value)))
{
lst.Add(obj);
}
}
}
}

grdCatalogo.DataSource = lst;
grdCatalogo.DataBind();
grdCatalogo.FolderStyle = "~/App_Themes/" + Page.Theme + "/styles/oboutgrid";
}
catch (CDISException ex)
{
MostrarErrorGeneral(ex.ErrorMessage);
ErrorOboutGrid = ex.ErrorMessage;
}
catch (Exception exGeneral)
{
MostrarErrorGeneral("Ocurrió un error inesperado. Verifique la información ingresada y contacte con el encargado de la aplicación.");
ErrorOboutGrid = "Ocurrió un error inesperado. Contacte con el encargado de la aplicación.";
}
}

最佳答案

看起来您实际上是将“打开模态对话框”代码挂接到 tplIndividualQuotations 中的链接上通过基于 class="modal" 的 JavaScript ?

我相信您执行此操作的代码只会在页面加载时触发一次(使用类似 jQuery $() 方法或类似方法)。

问题是当 UpdatePanel 被重新加载时,这段代码不会再次运行并 Hook 新的 <a> 上的代码。已添加到页面的元素。

当您使用 UpdatePanels 时,您将需要连接到 ASP.NET AJAX PageRequestManager

您需要向 endRequest 添加一个方法事件 Hook 是:

Raised after an asynchronous postback is finished and control has been returned to the browser.

所以你会有这样的东西:

<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(pageLoaded);

function pageLoaded(sender, args) {
//Code to hook up modal load here...
}
</script>

关于c# - 如何在更新面板中打开模态弹出窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25654651/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com