locked
Modal popup problem RRS feed

  • Question

  • User-962670764 posted

    I have a modal popup that is part of the master page that opens a login  form when triggered. This opens as it should and you can log in.

    I then copied the code to a master page in another solution, but  there the popup will not display.  When you click on the login link, the cursor goes to the right method and goes through it without  error, but the popup never shows. Herer's the code:

    public partial class Main_MasterPage : System.Web.UI.MasterPage
    {
        public string odometervalue;
        //public string odocurrentvalue;
        protected void Page_Load(object sender, EventArgs e)
        {
            stats st = new stats();
            odometervalue = st.getbdtotals();
    
            ContentPlaceHolder cph1;
    
            Literal l1;
            cph1 = (ContentPlaceHolder)this.Page.Master.FindControl("ContentPlaceHolder1");
            if (cph1 != null)
            {
                l1 = (Literal)cph1.FindControl("Literal1");
                l1.Text = odometervalue;
            }
        }
    
        protected void LinkLogin_Click(object sender, EventArgs e)
        {
            pLogin_ModalPopupExtender.Show();
        }
    
        protected void Login1_LoggedIn(object sender, EventArgs e)
        {
             TextBox userName = (TextBox)Login1.FindControl("UserName");
            string uname = userName.Text;
            TextBox Password = (TextBox)Login1.FindControl("Password");
            if (Membership.ValidateUser(userName.Text, Password.Text) == true)
            {
                CheckBox rememberMe = (CheckBox)Login1.FindControl("RememberMe");
    
                bool PersistMe = rememberMe.Checked;
    
                rider bd = new rider();
    
                string UserData = bd.getRidFromUsername(uname).ToString();
                
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, uname, DateTime.Now, DateTime.Now.AddMonths(3), false, FormsAuthentication.FormsCookiePath);
                string encryptedTicket = FormsAuthentication.Encrypt(ticket);
                HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                if (PersistMe == true)
                    authCookie.Expires = DateTime.Now.AddMonths(3);//make sure its same as the formsauthentication ticket expiry value
    
                Response.Cookies.Add(authCookie);
                rider rd = new rider();
                int albumid = 0;
                if( ! rd.albumexists(Convert.ToInt32(UserData),"Profile" , 1 ))
                    rd.createalbum(Convert.ToInt32(UserData), "Profile", 1, albumid);
            
                Response.Redirect("~/Main/Home.aspx");
            }
        }

    and the design code:

    <head runat="server">
        <title>Big Dogs</title>
        <asp:ContentPlaceHolder id="head" runat="server">
            <link href="../Content/main.css" rel="stylesheet" />
            <link href="Content/Site.css" rel="stylesheet" />
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
           <%-- <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager>--%>
            <link href="../Content/CSS.css" rel="stylesheet" />
            <script src="../Scripts/Extension.min.js"></script>
            <link href="../Content/odometer-theme-car.css" rel="stylesheet" />
    <link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
    <style>
    .odometer {
      font-size: 40px;
    }
    </style>
    
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    
    <script src="../Scripts/odometer.js"></script>
        <div>
            <div class="mypages">
            <%--<div style="background-color:gainsboro; height:20; float:right; padding-right:px; ">--%>
             <section id="login">
                        <asp:LoginView ID="LoginView1" runat="server" ViewStateMode="Disabled">
                            <AnonymousTemplate>
                                <ul>
                                    <li><a id="registerLink" runat="server" href="~/Account/Registrar.aspx">Register</a></li>
                                    <li><asp:LinkButton ID="LinkLogin" runat="server" Text="Log in" OnClick="LinkLogin_Click" /></li>
    
                                </ul>
                            </AnonymousTemplate>
                            <LoggedInTemplate>
                                <p>
                                    <asp:Label ID="lGreeting" runat="server" /><a id="A1" runat="server" class="username" href="/Profile/myProfile.aspx" title="Manage your account"  >View My Profile
                                        <%--<asp:LoginName runat="server" CssClass="username" />--%>
                                    </a>!
                                    <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/Account/LOGOUT.aspx" />
                                </p>
                            </LoggedInTemplate>
                        </asp:LoginView>
                    </section>
            <div>
              <div>
                
            </div>
            <div style="width:1000px; margin-top:25; padding-top:10px" >
                <asp:Image ID="imglogo" runat="server" ImageUrl="~/Images/Site/doglogomain.png" />
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BDUCConnectionString %>" SelectCommand="adminRiderInfo" SelectCommandType="StoredProcedure">
                    <SelectParameters>
                        <asp:Parameter Name="riderid" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </div>
            
    
            <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Icons/user_silhouette.png" /><asp:HyperLink ID="hlToday" runat="server" Text="Today's Posts" Font-Size="Large" NavigateUrl="~/Main/todaysPosts.aspx" ToolTip="Who's Riding?" />
             <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/Icons/medal_bronze_1.png" style="margin-left:10px;" /><asp:HyperLink ID="hlstndings" runat="server" Text="Leaderboard" NavigateUrl="~/Main/leaderboard.aspx" Font-Size="Large" />
            <asp:Image ID="Image3" runat="server" ImageUrl="~/Images/Icons/ccLogoicon.png" style="margin-left:10px;" />
            <asp:HyperLink ID="hlcc" runat="server" Text="Century Challenge"  CssClass="th" Font-Size="Large" NavigateUrl="~/Main/centuryChallenge.aspx" />
             <asp:Image ID="Image4" runat="server" ImageUrl="~/Images/Icons/blueprint.png" style="margin-left:10px;" />
            <asp:HyperLink ID="lnklgs" runat="server" Text="Logbook"  CssClass="th" Font-Size="Large" NavigateUrl="~/Main/Posts.aspx" />
            
                <br />
                <hr />
            
        </div>
            <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
           
            </asp:ContentPlaceHolder>
        </div>
            
            <asp:Panel ID="pLogin" runat="server" CssClass="gainsPanel" style="display:none" >
                <asp:Login ID="Login1" runat="server" Width="225px" OnLoggedIn="Login1_LoggedIn" OnLoginError="Login1_LoginError" BackColor="White"  >
                    <LayoutTemplate>
                        <table  style="border-collapse:collapse; padding:1px;">
                            <tr>
                                <td>
                                    <table >
                                        <tr>
                                            <td style="text-align:center" colspan="2">
                                                <%--<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>--%>
                                                <strong>Log In</strong></td>
                                        </tr>
                                        <tr>
                                            <td class="tdreq"></td>
                                            <td class="tdlt_150">
                                                <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
                                                <br />
                                                <asp:TextBox CssClass="txlt_150" ID="UserName" runat="server"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="ctl00$Login1" />
                                                
                                            </td>
                                        </tr>
                                        
                                        <tr>
                                            <td class="tdreq">
                                                
                                            </td>
                                            <td class="tdlt_150"><asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label><br />
                                                <asp:TextBox ID="Password" runat="server" TextMode="Password" CssClass="txlt_150" />
    
                                                <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="ctl00$Login1" />
                                               <%-- <ajaxToolkit:ValidatorCalloutExtender ID="PasswordRequired_ValidatorCalloutExtender" runat="server" Enabled="True" TargetControlID="PasswordRequired">
                                                </ajaxToolkit:ValidatorCalloutExtender>--%>
                                              
                                                </tr>
                                        <tr>
                                            <td colspan="2">
                                                <asp:CheckBox ID="RememberMe" runat="server" Text="Remember me next time." />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" colspan="2" style="color:Red;">
                                                <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="" colspan="2">
                                                <asp:Button ID="Button1" runat="server" Text="Cancel" />
                                                &nbsp;<asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In"   />
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </LayoutTemplate>
                </asp:Login>
                </asp:Panel>
                <asp:Button ID="btnpop" runat="server" Text="Button" style="display:none" />
            <asp:ModalPopupExtender ID="pLogin_ModalPopupExtender" runat="server" Enabled="True" CancelControlID="Button1" OkControlID="LoginButton" TargetControlID="pLogin" PopupControlID="btnpop" />
            
            <
        </div>
    
    
        </form>
        <script>
            setTimeout(function () {
                var uid = '<%=odometervalue  %>';
            $('.odometer').html(uid);
        }, 1000);
    </script>
    </body>
    </html>

    Friday, November 7, 2014 9:05 AM

All replies

  • User1508394307 posted

    Did you try to check if there is any js error occurred? In browser go to Developer Tools F12 and see console.  

    Also make sure that html is correct, currently I see missing < between asp:ModalPopupExtender and last </div>

    Friday, November 7, 2014 9:20 AM