Bootstrap Modal Popup Window not firing

Last Reply 11 days ago By pandeyism

Posted 14 days ago

Hello, I am guiding myself in this example to adapt it to my website

https://www.aspsnippets.com/Articles/Open-Show-Bootstrap-Modal-Popup-Window-on-Page-Load-in-ASPNet.asp 

My site has a master page and a daughter page. I add my code of how I'm doing this:

index.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Principal.Master" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="CapaPresentacion.index" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
    .auto-style2 {
        width: 73%;
    }
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
     
    <!-- Bootstrap -->
    <script type="text/javascript" src='https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js'></script>
    <script type="text/javascript" src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js'></script>
    <link rel="stylesheet" href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css' media="screen" />

    <script type="text/javascript">
    function ShowPopup(title, body) {
        $("#Popup .modal-title").html(title);
        $("#Popup .modal-body").html(body);
        $("#Popup").modal("show");
    }
</script>

        <div id="content-wrapper" class="auto-style2">
         <ol class="breadcrumb">
            <li class="breadcrumb-item">
              <a href="#">Teleperformance</a>
            </li>
             <asp:label ID="Menu" class="breadcrumb-item active" runat="server"></asp:label> 
            <li class="breadcrumb-item active"></li>
         </ol>

            <br />
            <asp:FileUpload ID="Upload" runat="server" Width="632px"  CssClass="auto-style3" Enabled="true" EnableTheming="True" />
            <br />
             
            <asp:Button ID="btnvisualizarArchivo" cssClass="btn btn-primary" runat="server" Text="Visualizar" OnClick="visualizarArchivo_Click" />

            <asp:Button ID="btnCargarArchivo" cssClass="btn btn-primary" runat="server" Text="Cargar" OnClick="CargarArchivo_Click"  />

            <div id="Popup" class="modal fade" role="dialog">
            <div class="modal-dialog">
        <!-- Modal content-->
            <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    &times;</button>
                <h4 class="modal-title">
                </h4>
            </div>
            <div class="modal-body">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger" data-dismiss="modal">
                    Close</button>
            </div>
        </div>
    </div>
    </div>
            <br />
            
            <br />
            <br />
            <div style="overflow-x: auto; overflow-y:hidden">
            <asp:GridView ID="grdEjemplo" runat="server" HorizontalAlign="left" Width="860px" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" AutoGenerateColumns="true"  HeaderStyle-HorizontalAlign="Center" RowStyle-HorizontalAlign="Center" AllowPaging="true" OnPageIndexChanging="grdEjemplo_PageIndexChanging" PageSize="4" CssClass="table table-striped table-hover table-condensed small-top-margin" >
                <FooterStyle BackColor="White" ForeColor="#000066" />
                <HeaderStyle CssClass="grid-header" BackColor="#006699" Font-Bold="True"  ForeColor="White" Font-Size="small" />
                <PagerSettings FirstPageText="" LastPageText="" PageButtonCount="4" />
                <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                <RowStyle ForeColor="#000066" Font-Size="Small" />
                <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                <SortedAscendingHeaderStyle BackColor="#007DBB" />
                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                <SortedDescendingHeaderStyle BackColor="#00547E" />
            </asp:GridView>
             </div>
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />

                  </div>         
</asp:Content>

index.cs 

protected void LoadFile_Click(object sender, EventArgs e)
        {
            executeSP(); 
        }
 public void executeSP()
        {
            SqlDataReader dataReader;
            string message = "";
            try
            {
                string constr = ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString;
                using (SqlConnection con = new SqlConnection(constr))
                {
                    con.Open();
                    SqlCommand command = new SqlCommand("sp_Process_MenuWEB", con);
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandTimeout = 3600;

                    SqlParameter parameter1 = command.Parameters.Add("@id", SqlDbType.NVarChar);
                    parameter1.Value = idUpload.ToString();

                    SqlParameter parameter2 = command.Parameters.Add("@UserId", SqlDbType.NVarChar);
                    parameter2.Value = Session["UserId"].ToString();

                    dataReader = command.ExecuteReader();

                    while (dataReader.Read())
                    {
                        message = message +  dataReader["Observation"].ToString() + "//n";
                    }
                
                    string title = "Tittle";
                    ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup('" + title + "', '" + message + "');", true);
                }
            }
            catch (Exception ex)
            {
                ErrorLogging(ex);
            }
        }

The variable message is cumulative because the stored procedure can return a successful process or several errors at the same time and I need to show them all.

But I can not get the modal window to show. What is the problem ?

You are viewing reply posted by: pandeyism 11 days ago.
Posted 11 days ago

Hi fredo1094,

If you are looking for accessing master page control in content page so refer below links :

Access control declared in Master Page in Content Page using ASP.Net

Access Master Page Controls in Content Pages in ASP.Net