Logesh Kumar

Logesh Kumar

  • 1.5k
  • 243
  • 31.6k

Modal Pop Up in ASP.Net

Jul 1 2019 11:51 PM
In Link Button Click To Open Modal Correctly
 
But click close button not close...what is the reason i dont know..the close button not triggered....
 
My Code...
  1. <asp:LinkButton ID="lnkbtnSalesLead" runat="server" Text="10" Font-Size="16px" OnClick="lnkbtnSalesLead_Click"></asp:LinkButton><br />  
  2. <div class="container" id="divModal" runat="server">  
  3. <!-- Modal -->  
  4. <div class="modal-dialog">  
  5. <!-- Modal content-->  
  6. <div class="modal-content">  
  7. <div class="modal-header">  
  8. <button type="button" class="close" data-dismiss="modal">×</button>  
  9. <h4 class="modal-title">Sales Lead Details</h4>  
  10. </div>  
  11. <div class="modal-body">  
  12. <asp:GridView ID="gvLead" runat="server" AutoGenerateColumns="False" CssClass="table table-bordered table-condensed">  
  13. <Columns>  
  14. <asp:TemplateField HeaderText="Emp Name">  
  15. <ItemTemplate>  
  16. <asp:Label ID="lblEmpName" runat="server" Text='<%# Bind("EmpName") %>'></asp:Label>  
  17. </ItemTemplate>  
  18. <ItemStyle HorizontalAlign="Center" />  
  19. </asp:TemplateField>  
  20. <asp:TemplateField HeaderText="Client Code">  
  21. <ItemTemplate>  
  22. <asp:Label ID="lblCustomerName" runat="server" Text='<%# Bind("CustomerName") %>'></asp:Label>  
  23. </ItemTemplate>  
  24. <ItemStyle Horizontal />  
  25. </asp:TemplateField>  
  26. <asp:TemplateField HeaderText="Sales Lead Stage">  
  27. <ItemTemplate>  
  28. <asp:Label ID="lblSalesLeadStage" runat="server" Text='<%# Bind("SalesLeadStage") %>'></asp:Label>  
  29. </ItemTemplate>  
  30. <ItemStyle HorizontalAlign="Center" />  
  31. </asp:TemplateField>  
  32. <asp:TemplateField HeaderText="Meeting Date">  
  33. <ItemTemplate>  
  34. <asp:Label ID="lblMeetingDate" runat="server" Text='<%# Bind("MeetingDate") %>'></asp:Label>  
  35. </ItemTemplate>  
  36. <ItemStyle Horizontal />  
  37. </asp:TemplateField>  
  38. </Columns>  
  39. <PagerStyle HorizontalAlign="Center" CssClass="GridPager" />  
  40. <HeaderStyle CssClass="grdHead" />  
  41. <RowStyle BackColor="White" />  
  42. <FooterStyle BackColor="White" ForeColor="#000066" />  
  43. </asp:GridView>  
  44. </div>  
  45. <div class="modal-footer">  
  46. <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>  
  47. </div>  
  48. </div>  
  49. </div>  
  50. </div>  
  51. </div>  
  52. <script type='text/javascript'>  
  53. function openModal() {  
  54. $('[id*=myModal]').modal('show');  
  55. }  
  56. </script>  
  1. protected void lnkbtnSalesLead_Click(object sender, EventArgs e)  
  2. {  
  3. string sQuery = string.Empty;  
  4. string sError = string.Empty;  
  5. DataTable dtbl = new DataTable();  
  6. ImageButton Imgbtn = sender as ImageButton;  
  7. GridViewRow gvrow = lnkbtnSalesLead.NamingContainer as GridViewRow;  
  8. //hfUniqueId.Value = gvLead.DataKeys[gvrow.RowIndex].Value.ToString();  
  9. //Label sUserId = (Label)gvrow.FindControl("lblLeadId");  
  10. try  
  11. {  
  12. divModal.Visible = true;  
  13. sQuery = " My Database query";  
  14. objHelper.CreateConnection("Connect");  
  15. if (objHelper.FillDataTableByQueryString(ref dtbl, ref sError, sQuery) == true)  
  16. {  
  17. if (dtbl.Rows.Count > 0)  
  18. {  
  19. gvLead.DataSource = dtbl;  
  20. gvLead.DataBind();  
  21. ClientScript.RegisterStartupScript(this.GetType(), "Pop""openModal();"true);  
  22. }  
  23. }  
  24. else  
  25. {  
  26. Page.Controls.Add(new LiteralControl("<script>alert('" + sError + "');</script>"));  
  27. return;  
  28. }  
  29. }  
  30. catch (Exception ex)  
  31. {  
  32. Page.Controls.Add(new LiteralControl("<script>alert('" + ex.Message.Replace("'""").Replace("\n""").Replace("\r""") + "');</script>"));  
  33. return;  
  34. }  
  35. }  

Answers (4)