Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 25th, 2016, 10:31 AM
Registered User
 
Join Date: May 2015
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Login Control not working inside updatepanel

Hi,

Refer book "Beginning ASP.NET 4.5 in C# and VB". I putted a loginstatus control on masterpage (Fronend.Master) and tried to add extender (ModalPopupExtender). the login control is inside a panel and when login is clicked the login control appears (in sql server 2008 r2, the user and membership tables are also made by login control).

But when i click login button, nothing happens. I have tried to google it for 2 days, now I'm knocking your door.

Below is the code for master page.

Code:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Frontend.master.cs" Inherits="FashionReplica.MasterPages.Frontend" %>

<%@ Register Src="~/Controls/LoginControl.ascx" TagPrefix="uc1" TagName="LoginControl" %>
<%@ Register 
Src="~/Management/ManagementControls/LoginModalControl.ascx" TagPrefix="uc1" TagName="LoginModalControl" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>

<%//@ Register Src="~/Controls/topLoginUserStrip.ascx" TagPrefix="uc1" TagName="topLoginUserStrip" %>




<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>My Site Title</title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
    <link href="../Styles/styles.css" rel="stylesheet" />
    <script src="../Scripts/modernizr-2.8.3.js"></script>
    
    <link href="../Styles/button.css" rel="stylesheet" />    
    <link href="../Styles/dd.css" rel="stylesheet" />
    <link href="../Styles/dialog.css" rel="stylesheet" />    
    <link href="../Styles/jquery-ui.css" rel="stylesheet" />        
    
    <script src="../Scripts/jquery-2.2.1.js"></script>    
    <script src="../Scripts/jquery-ui-1.11.4.js"></script>    
    <script src="../Scripts/jquery-ui.js"></script>    
    <script src="../Scripts/modernizr-2.8.3.js"></script>

</head>
<body id="body">

    <form id="form1" runat="server">
        
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" EnablePartialRendering="true">
            <Scripts>
                <asp:ScriptReference Path="~/Scripts/jquery-2.1.4.min.js" />
            </Scripts>
        </asp:ScriptManager>    
        
    <div>
        <asp:UpdatePanel UpdateMode="Conditional" runat="server">
            <ContentTemplate>
        <asp:Panel runat="server" ID="Pan1" CssClass="modalPopup">                
                <asp:Login ID="Login1" runat="server" CreateUserText="SignUp" CreateUserUrl="~/Signup.aspx" FailureText="Wrong ID/Password"></asp:Login>
            </asp:Panel>
                </ContentTemplate>
        </asp:UpdatePanel>
        <asp:LoginStatus ID="LoginStatus1" runat="server" />
        
        <ajaxToolkit:ModalPopupExtender ID="LoginStatus1_ModalPopupExtender" runat="server" CancelControlID="btnCancle" BehaviorID="LoginStatus1_ModalPopupExtender" TargetControlID="LoginStatus1" PopupControlID="Pan1">
        </ajaxToolkit:ModalPopupExtender>
        
        <div class="site-title"><a href="http://p2p.wrox.com/Default.aspx">Site Title</a></div>
        <div id="loginModalUserControl" style="display:none;">
            <uc1:LoginControl runat="server" id="LoginControl" />
        </div>
        <nav>
            <ul id="menu">
                <li>
                <a href="http://p2p.wrox.com/Default.aspx">Home</a>
                   </li>
                <li>
                    <a href="http://p2p.wrox.com/About.aspx">About Us</a>
                </li>
                <li>
                    <a href="http://p2p.wrox.com/Conact.aspx">Conact Us</a>
                </li>
                <li>
                    <a href="http://p2p.wrox.com/Management/Add Brand.aspx">Add Brand</a>
                </li>
            </ul>

        </nav>
        
        <asp:ContentPlaceHolder ID="FirstContent" runat="server">
                        
        </asp:ContentPlaceHolder>
        
        <footer>© 2016 - Site Title</footer>
    </div>
    </form>
</body>
</html>

Last edited by sohaibtoosy; April 25th, 2016 at 10:34 AM.. Reason: To Mention code blocks
 
Old April 25th, 2016, 03:26 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Can you define "nothing happens"? Have you looked at outgoing requests with a tool like Fiddler or the Network tools in your browser? It may be doing something you're not seeing.

Not sure if this would even work. Logging in sets a cookie which needs to be sent to the browser and then be sent back to the server on the next request. You usually need a Redirect after a Login action to make it work.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old April 25th, 2016, 04:04 PM
Registered User
 
Join Date: May 2015
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Imar,

Thanks for replying. Nothing means when I put login control inside updatepanel, clicking login button of login control shows no changes, or even failuretext in case of wrong user/pass.

As you have suggested i will make sure if anything is posted back by clucking button. Everything works fine when i use a separate login page instead of modal popup.

May b i have placed the loginstatus and login controls at wrong places. However, login control in same state was able to create user tables in sql server 2008 r2.

I cab share my code with you if you require.
 
Old April 25th, 2016, 05:28 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

>> However, login control in same state was able to create user tables in sql server 2008 r2.

Yes, but that control works differently because it doesn't depend on cookies immediately (unless you auto login the new user)

>> I cab share my code with you if you require.

I don't think that would help in this case. There's probably nothing wrong with the code per se, but with the process which would be hard to see from the code alone. You'll need to do some further debugging and testing to make this work.

Did you look at similar problems with Logjn and an UpdatePanel? E.g.

http://stackoverflow.com/questions/2...ull%20postback

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old April 30th, 2016, 03:52 PM
Registered User
 
Join Date: May 2015
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Imar,

Thanks alot for your suggestion, and I have tried to postback in updatepanel triggers, both AsyncPostBackTrigger and PostBackTrigger.

Using PostBackTrigger causes the page to refresh and the login modal popup vanishes. I have to click on loginstatus control again which shows the faliure text of login control.

Trying to configure fiddler for AsyncPostBackTrigger. Is there anyway I can use VS13 to identify that login button on login control is causing event call using AsyncPostBackTrigger? Can't find click event for login so that I can place a breakpoint to know if button is still causing event to fire.

Regards,
Sohaib Toosy
 
Old May 4th, 2016, 02:43 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

The control doesn't expose the Button's click event directly, but it should have something like OnLoggingIn.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 8th, 2016, 01:46 AM
Registered User
 
Join Date: May 2015
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy

Dear Imar,

Thanks alot for your suggestion. I have tested and OnLoggingIn is fired when I click Login button of Login control from within Ajax Modal popup.

But unfortunately, my problem still persists and I am unable to understand why Login control is behaving like this. It was supposed to show FailureText or allowed user to login.
 
Old May 8th, 2016, 10:56 AM
Registered User
 
Join Date: May 2015
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I have also tried this;

Code:
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Login1" EventName="LoggingIn" />
            </Triggers>
            <ContentTemplate>
        <asp:Panel runat="server" ID="Pan1" style="display:none;" CssClass="modalPopup">
                <asp:Login ID="Login1" runat="server" CreateUserText="SignUp" CreateUserUrl="~/Signup.aspx" FailureText="Wrong ID/Password" OnLoggingIn="Login1_LoggingIn"></asp:Login>
            </asp:Panel>
        </ContentTemplate>
        </asp:UpdatePanel>
Even with trigger, no luck. When I use postbacktrigger, the whole page is posted back, like the page refresh and popup is not shown anymore, when i click on loginstatus again, popup appears with failure text.

Kindly guide further.
 
Old May 8th, 2016, 05:17 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Like i said, it may not work at all without some additional work: http://ajax.asp.net/ajax/documentati...atibleControls

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!

Last edited by Imar; May 8th, 2016 at 05:20 PM..
 
Old May 18th, 2016, 12:36 PM
Registered User
 
Join Date: May 2015
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Imar,

Thanks for your tip. I have found that the control is actually working if correct ID/Password are given. Its only the literal control that is not updating inside update panel when wrong ID/Password are given. I converted the login control into template.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Login control with username dropdown not working Raj BOOK: Professional ASP.NET 3.5 Security, Membership, and Role Management ISBN: 978-0-470-37930-1 1 April 6th, 2012 04:21 PM
Login Control and create user wizard is not working in hosting space ramesh ASP.NET 4 General Discussion 2 February 2nd, 2012 12:07 PM
GridView inside UpdatePanel not Uploading Image Manoj Bisht ASP.NET 3.5 Professionals 8 September 16th, 2009 03:34 AM
If Else Condition not working inside the submittButton_Click function/method skhan ASP.NET 3.5 Professionals 4 August 26th, 2009 04:21 PM
The control that triggered the UpdatePanel control Kika ASP.NET 2.0 Professional 0 January 17th, 2008 01:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.