Thank you, @Z.
Just to clarify - I would personally prefer a working v1 sample with a DirectEvent request. Before I was never able to get it working without a hard PostBack. It would be a great lesson for me.
Printable View
Thank you, @Z.
Just to clarify - I would personally prefer a working v1 sample with a DirectEvent request. Before I was never able to get it working without a hard PostBack. It would be a great lesson for me.
This is a full example for v1.7.
It has worked on Chrome and my Android (kitkat now) for about 2 years. Also worked on a bunch of other machines and properly saved passwords in v1.7
Thanks,
/Z
Code:
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test</title>
<style type="text/css">
h1 {
font: normal 60px tahoma, arial, verdana;
color: #E1E1E1;
}
h2 {
font: normal 20px tahoma, arial, verdana;
color: #E1E1E1;
}
h2 a {
text-decoration: none;
color: #E1E1E1;
}
.align-right {
float: right;
}
.x-window-mc {
background-color : #F4F4F4 !important;
}
</style>
<script type="text/javascript">
var funcFocus = function (field) {
field.focus();
}
if (window.top.frames.length !== 0) {
window.top.location = self.document.location;
}
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Window
ID="LoginWindow"
runat="server"
Closable="false"
Resizable="false"
AutoHeight="true"
Icon="Lock"
Title="Login"
Draggable="true"
Width="300"
Modal="true"
Layout="fit"
BodyBorder="false"
Padding="5">
<Items>
<ext:FormPanel
runat="server"
FormID="loginForm"
Border="false"
Layout="form"
BodyBorder="false"
BodyStyle="background:transparent;"
Url='<%# Html.AttributeEncode(Url.Action("Login")) %>'>
<Items>
<ext:TextField
ID="txtUsername"
runat="server"
FieldLabel="Username"
AllowBlank="false"
BlankText="Username is required."
Text=""
AutoFocus="true"
AutoFocusDelay="100"
AnchorHorizontal="100%"
>
</ext:TextField>
<ext:TextField
ID="txtPassword"
runat="server"
InputType="Password"
FieldLabel="Password"
AllowBlank="false"
BlankText="Password is required."
Text=""
AnchorHorizontal="100%"
/>
</Items>
<KeyMap>
<ext:KeyBinding>
<Keys>
<ext:Key Code="ENTER" />
</Keys>
<Listeners>
<Event Handler="Ext.getCmp('LoginButton').fireEvent('click')" />
</Listeners>
</ext:KeyBinding>
</KeyMap>
</ext:FormPanel>
</Items>
<Buttons>
<ext:Button ID="LoginButton" runat="server" Text="Login" Icon="Accept">
<DirectEvents>
<Click
Url="/Login/"
Timeout="60000"
FormID="loginForm"
CleanRequest="true"
Method="POST"
Before="Ext.Msg.wait('Verifying...', 'Authentication');"
Failure="Ext.Msg.show({
title: 'Login Error',
msg: result.message || result.errorMessage,
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});">
<EventMask MinDelay="250" />
</Click>
</DirectEvents>
</ext:Button>
</Buttons>
</ext:Window>
</body>
</html>
Thank you.
I ran the test case in Chrome.
1. Type some Username and Password
2. Click the Login button
3. Chrome does NOT offer to save the password
Please clarify is the existing Login URL required to reproduce the password saving functionality? Could you, please, try to change the Login URL it to some fake URL and check if the password saving functionality still works for you or it doesn't?
:) i think going back and forth on this isnt the best use of time. hehe
I have been running that code for years and it worked for me. i have no idea how but take my word it did.
In any case, can you please post a sample that does work properly that i can post to a Controller? I think that would be simpler. i would recommend to add this to the examples explorer.
Thanks,
/Z
I agree.Quote:
:) i think going back and forth on this isnt the best use of time. hehe
Certainly, I took your word and there is no doubt. I am not looking for a proof of your word, but I am looking for your help to help you.Quote:
I have been running that code for years and it worked for me. i have no idea how but take my word it did.
Sure, it would be simpler, but I just could not get it working. I could get it working only with a hard PostBack. Though, I will try again.Quote:
In any case, can you please post a sample that does work properly that i can post to a Controller? I think that would be simpler.
Please clarify have you tested your code sample outside of the application where it works? Say, in a freshly created MVC project. I assume there is something in your project that makes it working...
Thank you for the suggestion! Most likely we will.Quote:
i would recommend to add this to the examples explorer.
I still cannot get it working.
Posting View > Page Sources and the actual generated HTML after rendering might be helpful.
Only tested in the app. I have no idea why it worked. I don't have any public examples as we fully completed our migration from v1.7 to v3.2.1
Just post closest working example and I will review and tweak it as needed.
/Z
I've converted this example to Ext.NET MVC.
https://www.sencha.com/forum/showthr...=1#post1079672
View
ControllerCode:<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.Net.MVC v3 Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Window runat="server" Title="Login" Width="300">
<Items>
<ext:FormPanel runat="server" BodyPadding="10">
<AutoEl Tag="Form">
<CustomConfig>
<ext:ConfigItem Name="method" Value="POST" Mode="Value" />
<ext:ConfigItem Name="action" Value="/Aspx/Login/" Mode="Value" />
<ext:ConfigItem Name="target" Value="submitTarget" Mode="Value" />
</CustomConfig>
</AutoEl>
<Items>
<ext:TextField
runat="server"
Name="username"
FieldLabel="Username"
AllowBlank="false">
<CustomConfig>
<ext:ConfigItem Name="inputAttrTpl" Value="['autocomplete="on"']" Mode="Raw" />
</CustomConfig>
</ext:TextField>
<ext:TextField
runat="server"
Name="password"
FieldLabel="Password"
AllowBlank="false"
InputType="Password">
<CustomConfig>
<ext:ConfigItem Name="inputAttrTpl" Value="['autocomplete="on"']" Mode="Raw" />
</CustomConfig>
</ext:TextField>
<ext:Component runat="server" Html="<iframe id='submitTarget' name='submitTarget' style='display:none'></iframe>" />
<ext:Component runat="server" Html="<input type='submit' id='submitButton' style='display:none' />" />
</Items>
<Buttons>
<ext:Button
runat="server"
Text="Login"
FormBind="true"
Handler="Ext.getElementById('submitButton').click();" />
<ext:Button
runat="server"
Text="Reset"
Handler="btn.up('form').getForm().reset();" />
</Buttons>
</ext:FormPanel>
</Items>
</ext:Window>
</body>
</html>
Code:public class AspxController : System.Web.Mvc.Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Login(string username, string password)
{
// Just to see in a response that username/password have been submitted
return this.Json(new
{
username = username,
password = password
});
}
}
so the good news is that the example definitely prompts me to save my password and that works great.
however, when i click Login, i am prompted to Open the json. i expected it to redirect me to the location. I guess that is on my side and i will see what is going on. let me review more.
ok. my controller does this on success:
since we are no longer MVC, this is not invalid and just prompts me to open it in notepad :)Code:return new Ext.Net.MVC.DirectResult("window.location='/ta/Home/Index';");
Thanks,
/Z
Yes, that submitting (via<input type='submit' ...
) is not a DirectEvent and a DirectResult cannot be used.
I tried this:
But redirection happens in a hidden iframe, because ofCode:public ActionResult Login(string username, string password)
{
return this.Redirect("other URL");
}
Personally, I am not sure why it is required and I tried to remove it.Code:<ext:ConfigItem Name="target" Value="submitTarget" Mode="Value" />
As well as
It looks like it still triggers password saving and redirection works well.Code:<ext:Component runat="server" Html="<iframe id='submitTarget' name='submitTarget' style='display:none'></iframe>" />
Please try.