[CLOSED] Login MVC application

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Login MVC application

    Hi,

    We are trying to migrate from Ext.NET 1.2 to 2.0. After several adjustments, we stopped on this issue.
    When the user posts a login form to the server, the textfield values are not passed to our method on the controller. We get null on our arguments txtUsername and txtPassword.


    Can you send me the MVC Application Demo ?


    Regards
    Last edited by Daniil; May 02, 2012 at 9:44 PM. Reason: [CLOSED]
  2. #2
    Hi,


    Quote Originally Posted by romeu View Post
    Can you send me the MVC Application Demo ?
    It has been not ported to Ext.NET v2 yet.

    Quote Originally Posted by romeu View Post
    When the user posts a login form to the server, the textfield values are not passed to our method on the controller. We get null on our arguments txtUsername and txtPassword.
    Can you provide a sample to reproduce?
  3. #3
    This is the Controller code:
    
    [AcceptVerbs(HttpVerbs.Post)]
    [HttpPost]
    public ActionResult Login(string txtUsername, string txtPassword)
    {
        if (!ValidateLogOn(txtUsername, txtPassword))
        {
            return new AjaxResult { ErrorMessage = "Usuário ou Senha incorretos." };
        }
    
        this.FormsAuth.SignIn(txtUsername, true);
    
        return this.RedirectToAction("Index", "Home");
    }
    
    And this is the view code: 
    
    <ext:Window ID="LoginWindow" runat="server" Closable="false" Resizable="false" Height="130"
            Icon="Lock" Title="Usuário/Senha" Draggable="true" Width="300" Modal="true" Layout="fit"
            Padding="5">
            <Items>
                <ext:FormPanel ButtonAlign="Center" runat="server" FormID="form1" Border="false"
                    ShowOnLoad="true" Layout="form" BodyStyle="background:transparent;" Url='<%# Html.AttributeEncode(Url.Action("Login")) %>'>
                    <Items>
                        <ext:TextField ID="txtUsername" Name="txtUsername" runat="server" FieldLabel="Usuário"
                            AllowBlank="false" BlankText="Usuário é obrigatório." Text="Adm" AnchorHorizontal="100%" />
                        <ext:TextField ID="txtPassword" runat="server" InputType="Password" FieldLabel="Senha"
                            AllowBlank="false" BlankText="Senha é obrigatória." Text="123456" Name="txtPassword" AnchorHorizontal="100%" />
                    </Items>
                </ext:FormPanel>
            </Items>
            <Buttons>
                <ext:Button runat="server" ID="button_login" Text="Entrar" Icon="Accept">
                    <DirectEvents>
                        <Click Url="~/Account/Login" Timeout="60000" FormID="form1" CleanRequest="true"
                            Method="POST" Before="Ext.Msg.wait('Verificando...', 'Autenticação');" Failure="Ext.Msg.show({
                               title:   'Erro na Autenticação',
                               msg:     result.errorMessage,
                               buttons: Ext.Msg.OK,
                               icon:    Ext.MessageBox.ERROR
                            });">
                            <EventMask MinDelay="250" />
                            <%--     <ExtraParams>
                                  <ext:Parameter Name="ReturnUrl" Value="Ext.urlDecode(String(document.location).split('?')[1]).r || '/'" Mode="Raw" />
                            </ExtraParams>--%>
                        </Click>
                    </DirectEvents>
                </ext:Button>
            </Buttons>
        </ext:Window>
  4. #4
    Hi,

    By default, FormPanel doesn't render html form
    Please add the following code to the form panel
    <AutoEl Tag="Form" />
  5. #5
    Hi,
    I have the same issue, I added the AutoEl but this doesn't fix... Do you you have other suggestion?
  6. #6
    Please post test sample
  7. #7
    This is my LogOn code

    <body>
        <ext:ResourceManager ID="MainScriptManager" runat="server" />
    
        <ext:Window 
            ID="LogOnWindow"
            runat="server" 
            Closable="false"
            Resizable="false"
            Height="150"
            Icon="Lock" 
            Title="MyApp - Logon"
            Draggable="true"
            Width="300"
            Modal="true"
            Layout="FitLayout"
            BodyStyle="padding:17px 15px 17px 15px;"
            ButtonAlign="Center">
            <Items>
                <ext:FormPanel
                    runat="server"    
                    DefaultButton="btnLogOn" 
                    DefaultButtonStopEvent="true"
                    FormID="formLogOn"
                    Border="false" 
                    Layout="FormLayout"
                    BodyStyle="background:transparent;"
                    Url='<%# Html.AttributeEncode(Url.Action("LogOn")) %>'>
    
                    
                    <AutoEl Tag="Form" />
    
                    <Items>
                    
                        <ext:TextField
                            ID="txtUsername" 
                            runat="server" 
                            AutoFocus="true"
                            AutoFocusDelay="150"
                            FieldLabel="Nome Utente" 
                            AllowBlank="false"
                            BlankText="Nome Utente obbligatorio."
                            AnchorHorizontal="100%" />
    
                        <ext:TextField 
                            ID="txtPassword" 
                            runat="server" 
                            InputType="Password" 
                            FieldLabel="Password" 
                            AllowBlank="false" 
                            BlankText="Password obbligatoria."
                            AnchorHorizontal="100%" />
                    </Items>
                </ext:FormPanel>
            </Items>
            <Buttons>
                <ext:Button ID="btnLogOn" runat="server" Text="Logon" Icon="Accept">
                    <DirectEvents>
                        <Click
                            Url="~/Account/LogOn/" 
                            Timeout="10000"
                            FormID="formLogOn"
                            CleanRequest="true" 
                            Method="POST"
                            Before="Ext.Msg.wait('Autenticazione in corso...', 'Logon');"
                            Failure="Ext.Msg.show({
                               title:   'Errore in fase di Logon',
                               msg:     result.errorMessage,
                               buttons: Ext.Msg.OK,
                               icon:    Ext.MessageBox.ERROR,
                               fn:      function(btn) { #{txtUsername}.focus(false, 100); }
                            })">
                            <EventMask MinDelay="250" />
    
    
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button ID="btnCancel" runat="server" Text="Annulla" Icon="Decline">
                    <Listeners>
    
    
                        <Click Handler="#{LogOnWindow}.hide();" />
                    </Listeners>
                </ext:Button>
    
            </Buttons>
    
        </ext:Window>
    This is my AccountController Code

    
    ...
            [HttpPost]
            [UserHostAddress]
            [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings",
                Justification = "Needs to take same parameter type as Controller.Redirect()")]
            public ActionResult LogOn(string txtUsername, string txtPassword, /* string returnUrl, */ string userHostAddress)
            {
                string licenseError = null;
                if (!Core.LicenseHelper.CheckLicense(out licenseError))
                {
                    return new AjaxResult { ErrorMessage = licenseError };
                }
    ...
           }
    
    ...
    The issue is that txtUserName and txtPassword are always null when passed into Controller.

    Update: Please look also at the runtime generated code... Ext Net 1.x makes different html code...
    Attached Thumbnails Click image for larger version. 

Name:	LogOn_Comparison.jpg 
Views:	24 
Size:	103.5 KB 
ID:	6204  
    Last edited by MarzioPat; May 13, 2013 at 2:25 PM.
  8. #8
    Okay, I got it moving AutoEl outside the FormPanel!

        <ext:Window 
            ID="LogOnWindow"
            runat="server" 
            Closable="false"
            Resizable="false"
            Height="150"
            Icon="Lock" 
            Title="MyApp - Logon"
            Draggable="true"
            Width="300"
            Modal="true"
            Layout="FitLayout"
            BodyStyle="padding:17px 15px 17px 15px;"
            ButtonAlign="Center">
            
            <AutoEl Tag="Form" />
    
            <Items>
                <ext:FormPanel
                    runat="server"    
                    DefaultButton="btnLogOn" 
                    DefaultButtonStopEvent="true"
                    FormID="formLogOn"
                    Border="false" 
                    Layout="FormLayout" 
                    BodyStyle="background:transparent;"
                    Url='<%# Html.AttributeEncode(Url.Action("LogOn")) %>'>
    
                    <Items>
                    
                        <ext:TextField
                            ID="txtUsername"  
                            runat="server" 
                            AutoFocus="true"
                            AutoFocusDelay="150"
                            FieldLabel="Nome Utente" 
                            AllowBlank="false"
                            BlankText="Nome Utente obbligatorio."
                            AnchorHorizontal="100%" />
    
                        <ext:TextField 
                            ID="txtPassword" 
                            runat="server" 
                            InputType="Password" 
                            FieldLabel="Password" 
                            AllowBlank="false" 
                            BlankText="Password obbligatoria."
                            AnchorHorizontal="100%" />
                    </Items>
                </ext:FormPanel>
            </Items>
  9. #9
    Hi @MarzioPat,

    AutoEl should not be required at all.
  10. #10
    Quote Originally Posted by Daniil View Post
    Hi @MarzioPat,

    AutoEl should not be required at all.
    Okay, so why removing it from my .aspx page the generated HTML code is different (as you can see in my previous attachment) and the txtUserName and txtPassword are not properly passed into Controller?

    I am migrating from 1.x to 2.x and I downloaded 2.x from Ext .Net web site then I am following the CHANGELOG.
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Login MVC application
    By romeu in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Mar 05, 2012, 7:22 PM
  2. Replies: 0
    Last Post: Feb 23, 2012, 6:18 AM
  3. [CLOSED] SVN Login
    By ewgoforth in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 10, 2011, 5:46 PM
  4. login problem with Ext Login Control
    By Bruce2010 in forum 1.x Help
    Replies: 1
    Last Post: Nov 30, 2010, 4:35 PM
  5. login
    By garapos in forum 1.x Help
    Replies: 0
    Last Post: Aug 05, 2009, 1:15 AM

Posting Permissions