在 asp.net 中传递来自转发器的值后,模态弹出窗口不会打开

The modal pop up wont open after passing the values from repeater in asp.net

我有一个搜索网页,用户可以在其中申请工作。作业通过中继器控制显示。当用户单击应用按钮时,我希望弹出一个模式,其中包含两个包含公司电子邮件和工作名称的文本框。现在,当我当时没有通过 passing 时,模态会弹出,但是当我尝试从中继器传递值时,模态不会显示。我搜索了很多,甚至尝试了一些东西。通过我的尝试,我没有收到错误,但模式没有出现。这是我的代码 转发器的 .aspx 代码

  <asp:Repeater ID="RepterDetails" runat="server" OnItemCommand="RepterDetails_ItemCommand">  
<HeaderTemplate>  
<table style="border:1px solid; width:800px" cellpadding="2" cellspaing="2">  
<tr style=" color:#000000; font-size: large; font-weight: bold;">  
<td colspan="2">  
<b>JOBS Available</b>  
</td>  
</tr>  
</HeaderTemplate>  
<ItemTemplate>  
<tr>  
<td> 
<table style="border-top:3px solid; width:800px" >  
<tr>  
<td style="color:black" >  
COMPANY:  
<asp:Label ID="lblcmp" runat="server" Text='<%#Eval("cmp_name")%>' Font-Bold="true" ForeColor="black"/>  
</td>  
</tr>  
</table>  
</td>  
</tr>  
<tr>  
<td style="color:black">  
LOCATION:
<asp:Label ID="lbl_city" runat="server" Text='<%#Eval("city_name") %>' ForeColor="black"/>,
    <asp:Label ID="lbl_state" runat="server" Text='<%#Eval("state_name") %>' ForeColor="black"/>
</td>  
</tr>  
<tr>  
<td style="color:black">  
Job:
<asp:Label ID="lbl_jname" runat="server" Font-Bold="true" Text='<%#Eval("job_name") %>' ForeColor="black"/>
</td>  
</tr>
<tr>  
<td style="color:black">  
Job Details:
<asp:Label ID="lbl_jdet" runat="server" Text='<%#Eval("job_details") %>' ForeColor="black"/>
</td>  
</tr>
 <tr>  
<td style="color:black">  
Experience :
<asp:Label ID="lbl_jexp" runat="server" Text='<%#Eval("experience") %>' ForeColor="black"/>
</td>  
</tr>
<tr>  
<td style="color:black">  
Job-Type :
<asp:Label ID="lbl_jobtype" runat="server" Text='<%#Eval("job_type") %>' ForeColor="black"/>
</td>  
</tr>
<tr>  
<td>  
<table>  
<tr>    
<td style="color:black" >Comapny Email: <asp:LinkButton   ID="link_cemail" runat="server" CommandName='<%#Eval("cemail") %>' CommandArgument='<%#Eval("cemail") %>' Text='<%#Eval("cemail") %>'  ForeColor="black"  OnClick="link_cemail_Click" ></asp:LinkButton></td>  
</tr>  
</table> 
    <tr>
    <td>
        <asp:Button runat="server" ID="btn_apply" CommandName="popup" OnClick="btn_apply_Click" Text="apply"/>
        <script type="text/javascript">
    function openModal() {
        $('#exampleModal').modal('show');
    }
</script>
           <asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline">
              <ContentTemplate>
                  <asp:Button  runat="server" ID="btn_save" OnClick="btn_save_Click" AutoPostBack="true"  Text="Save" Height="34px"/>
              </ContentTemplate>
               <Triggers>
                  <asp:AsyncPostBackTrigger ControlID="btn_save" />
               </Triggers>
               </asp:UpdatePanel>
    </td>
        </tr>
</td>  
</tr>  
<tr>  
<td colspan="2"> </td>  
</tr>  
</ItemTemplate>  
<FooterTemplate>  
</table>  
</FooterTemplate>  
</asp:Repeater>  

模态代码

<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">

<div class="modal-dialog modal-dialog-centered"> <div class="modal-content">
  <div class="modal-header">
    <h5 class="modal-title" id="exampleModalLabel">Apply for Job</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  </div>
  <div class="modal-body">
    Company Email : <asp:TextBox ID="txt_email" runat="server"  ReadOnly="true"  ></asp:TextBox><br /><br />
      Job-Name :  <asp:TextBox ID="txt_app_jname" runat="server"  ReadOnly="true"></asp:TextBox>
  </div>
  <div class="modal-footer">
    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
    <button type="button" class="btn btn-primary">Save changes</button></div>
</div>

这是我背后的代码

protected void btn_apply_Click(object sender, EventArgs e)
    {
        RepeaterItem item = (sender as Button).Parent as RepeaterItem;
        string cemail = (item.FindControl("link_cemail") as System.Web.UI.WebControls.LinkButton).Text;
        txt_email.Text = cemail;

        ClientScript.RegisterStartupScript(GetType(), "popup", "openModal()", true);
    }

我试过了,没有收到任何错误,但我的模式没有打开。 有人可以帮助我吗?

这是我的建议:

  1. 我在 asp.net 个项目中使用 Ajaxtoolkit:http://www.ajaxtoolkit.net/

  2. 然后我在我的项目中添加dll

  3. 在我的 aspx 页面中,我添加了这一行以使用 ajax 控件

  4. 对于模态尖叫我做了下一个:

  • 二手ajx:ModalPopupExtender
  • 将模态框放入 asp 面板

我的代码简历:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajx" %>
<ajx:ModalPopupExtender ID="mppPagos" runat="server" PopupControlID="pnl_PagosModal" TargetControlID="lk_BusquedaPagos" BackgroundCssClass="modalBackground">
                                    </ajx:ModalPopupExtender> 
                                    <asp:HiddenField ID="lbl_IdAbono" Value="0" runat="server"/>
                                    <div class="form-group row">    
                                        <div class="control-label col-lg-offset-0 col-md-2 col-lg-2">
                                            <asp:LinkButton runat="server" CssClass="btn btn-success btn-sm" ID="lk_BusquedaPagos" Text=">> Agregar Pagos <<"></asp:LinkButton>
                                        </div>
                                        <div>
                                            <asp:Button ID="btn_EliminarPagosRenta" CssClass="btn btn-success btn-sm" runat="server" Text="Eliminar Pago" OnClick="btn_EliminarPagosRenta_Click" />
                                        </div>                                        
                                    </div>

<asp:Panel ID="pnl_PagosModal" runat="server" CssClass="panel EstiloPanel" ScrollBars="Vertical">
                                <asp:UpdatePanel ID="upl_ModalPagos" runat="server">
                                    <ContentTemplate>
                                    <div class="modal-dialog modal-lg">
                                        <div class="modal-content">
                                            <div class="modal-header">  
                                                <div class="close">
                                                    <asp:Button ID="btnCerrarModalPago" runat="server" Text="x" CssClass="btn-xs" OnClick="btnCerrarModalPago_Click"/>
                                                </div>                                                  
                                                <h5 class="modal-title">Pagos</h5>
                                                <asp:Label ID="lbl_ErrorPagos" runat="server" Text="" ForeColor="Red"></asp:Label>
                                            </div>
                                            <div class="modal-body">                                                    
                                                    <div class="tab-pane fade in active" id="tab3_1">                                                                          
                                                    <asp:HiddenField ID="HiddenField2"  runat="server"/>
                                                    <div class="form-group row">
                                                        <asp:Label ID="lbl_FormaPago" CssClass="control-label col-lg-offset-0 col-md-2 col-lg-2" runat="server" Text="Forma de Pago:"></asp:Label>
                                                        <div class="col-md-4 col-lg-3">                                                
                                                            <telerik:RadComboBox ID="rad_ddl_FormaPago" runat="server"  Height="100%" Width="100%" OnSelectedIndexChanged="rad_ddl_FormaPago_SelectedIndexChanged"
                                                                    ZIndex="10000000" AutoPostBack="true"
                                                                    EmptyMessage="Seleccionar Forma Pago" MarkFirstMatch="true" EnableLoadOnDemand="true">
                                                            </telerik:RadComboBox>                                                                
                                                        </div> 
                                                        <asp:Label ID="lbl_NumeroTarjeta" CssClass="control-label col-lg-offset-0 col-md-2 col-lg-2" runat="server" Text="Número de Tarjeta:"></asp:Label>
                                                        <div class="col-md-4 col-lg-3">
                                                            <asp:TextBox ID="txtNumeroTarjeta" CssClass="form-control"  runat="server"></asp:TextBox>
                                                        </div>                                                                                                                       
                                                    </div>
                                                    <div class="form-group row">
                                                        <asp:Label ID="lbl_MontoPago" CssClass="control-label col-lg-offset-0 col-md-2 col-lg-2" runat="server" Text="Monto Pago:"></asp:Label>
                                                        <div class="col-md-4 col-lg-3">
                                                            <asp:TextBox ID="txtMontoPago" CssClass="form-control"  runat="server"></asp:TextBox>
                                                        </div>
                                                        <asp:Label ID="lbl_Cambio" CssClass="control-label col-lg-offset-0 col-md-2 col-lg-2" runat="server" Text="Cambio:"></asp:Label>
                                                        <div class="col-md-4 col-lg-3">
                                                            <asp:TextBox ID="txtMontoCambio" CssClass="form-control"  runat="server"></asp:TextBox>
                                                        </div>
                                                    </div>  
                                                    <div class="form-group row">
                                                        <asp:Label ID="lbl_DescGarantia" CssClass="control-label col-lg-offset-0 col-md-2 col-lg-2" runat="server" Text="Descripción de garantía:" Visible="false"></asp:Label>
                                                        <div class="col-md-4 col-lg-3">
                                                            <asp:TextBox ID="txt_DescGarantia" CssClass="form-control"  runat="server" Visible="false"></asp:TextBox>
                                                        </div>                                                            
                                                    </div>                                      
                                                </div>
                                            
                                            </div>
                                            <div class="modal-footer">                
                                                <asp:Button ID="btnAgregarPago" runat="server" Text="Agregar Pago" CssClass="btn btn-success btn-sm" OnClick="btnAgregarPago_Click" />
                                                <asp:Button ID="btnAgregarMontoTarjeta" runat="server" Text="Agregar Monto Tarjeta" CssClass="btn btn-success btn-sm" OnClick="btnAgregarMontoTarjeta_Click" />
                                            </div>
                                        </div>
                                    </div>
                                    </ContentTemplate>                     
                                </asp:UpdatePanel>
                            </asp:Panel>