May 20, 2015, 12:22 PM
[CLOSED] Form authentication caused a problem with LoadControl and returning field values
Repost of I question I asked 2.x help
I'm having problems with the LoadControl method in combination with form authentication.
When I use form authentication my input fields are not filled with the Request.Form values.
How do I get this code to work in combination with Form authentication.
I'm using Ext.NET Pro version 2.5.2.10712
In my code I'm using a custom control, but I have managed to reproduce the symptoms when dynamically creating a window.
Request body with <authentication mode="Forms">
The value is pressent : 'UC_UCrfText=MyValue' but not set in the TextField
__EVENTTARGET=ctl02&__EVENTARGUMENT=UC_UCbtnWinAcc ept%7Cevent%7CClick&__VIEWSTATE=TCUIPNgzEvuclUQG%2 FYGG1y%2BgwNawPBpfhTltr0LUSsWgz7%2F%2FOvCRyJFQTUWk dtxWFr%2FPVsumi8qyPVpuHb%2BLcRoDRRdD46jwaIQRHp9JhL 6NSTxEPlpcBVcb4aeJ%2B%2F19l0X3jVk0vkNKlWBvN8dD2BKY lGxssI5KR6%2Fxz7XdGJT95kkExcYLNjho15WvD056&hdLoade d=loaded&__VIEWSTATEGENERATOR=F97A37F8&__EVENTVALI DATION=wsYSiEyyiSnsdWRP2gh%2BFb5UeCv44s8hrtcCxm0qA WACf4FEbfHYNpAhd%2FdH74LRhOD6cuXDcb1nM9D5mAABtHX1r l2MvzbySjadYzai1oBGPxCDvVZEetrXqmz4lUVj&UC_UCrfTex t=MyValue
Response body:
{script:"Ext.Msg.show({\"title\":\" InputValue = []\",\"buttons\":false});App.UC_UCmyWin.close();" }
Request body without <authentication mode="Forms">
The 'UC_UCrfText=MyValue' is pressent and also set in the TextField.
hdLoaded=loaded&__VIEWSTATEGENERATOR=F97A37F8&__EV ENTTARGET=ctl02&__EVENTARGUMENT=UC_UCbtnWinAccept% 7Cevent%7CClick&UC_UCrfText=MyValue
Response body:
{script:"Ext.Msg.show({\"title\":\" InputValue = [MyValue]\",\"buttons\":false});App.UC_UCmyWin.close();" }
WebForm.aspx
ExtUserControl.ascx
When using this in the web.config I cannot get the Textfield value
Thanks,
Marc
I'm having problems with the LoadControl method in combination with form authentication.
When I use form authentication my input fields are not filled with the Request.Form values.
How do I get this code to work in combination with Form authentication.
I'm using Ext.NET Pro version 2.5.2.10712
In my code I'm using a custom control, but I have managed to reproduce the symptoms when dynamically creating a window.
Request body with <authentication mode="Forms">
The value is pressent : 'UC_UCrfText=MyValue' but not set in the TextField
__EVENTTARGET=ctl02&__EVENTARGUMENT=UC_UCbtnWinAcc ept%7Cevent%7CClick&__VIEWSTATE=TCUIPNgzEvuclUQG%2 FYGG1y%2BgwNawPBpfhTltr0LUSsWgz7%2F%2FOvCRyJFQTUWk dtxWFr%2FPVsumi8qyPVpuHb%2BLcRoDRRdD46jwaIQRHp9JhL 6NSTxEPlpcBVcb4aeJ%2B%2F19l0X3jVk0vkNKlWBvN8dD2BKY lGxssI5KR6%2Fxz7XdGJT95kkExcYLNjho15WvD056&hdLoade d=loaded&__VIEWSTATEGENERATOR=F97A37F8&__EVENTVALI DATION=wsYSiEyyiSnsdWRP2gh%2BFb5UeCv44s8hrtcCxm0qA WACf4FEbfHYNpAhd%2FdH74LRhOD6cuXDcb1nM9D5mAABtHX1r l2MvzbySjadYzai1oBGPxCDvVZEetrXqmz4lUVj&UC_UCrfTex t=MyValue
Response body:
{script:"Ext.Msg.show({\"title\":\" InputValue = []\",\"buttons\":false});App.UC_UCmyWin.close();" }
Request body without <authentication mode="Forms">
The 'UC_UCrfText=MyValue' is pressent and also set in the TextField.
hdLoaded=loaded&__VIEWSTATEGENERATOR=F97A37F8&__EV ENTTARGET=ctl02&__EVENTARGUMENT=UC_UCbtnWinAccept% 7Cevent%7CClick&UC_UCrfText=MyValue
Response body:
{script:"Ext.Msg.show({\"title\":\" InputValue = [MyValue]\",\"buttons\":false});App.UC_UCmyWin.close();" }
WebForm.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>
<script runat="server">
const string controlUrl = @"ExtUserControl.ascx";
private UserControl currentUC;
protected void Page_Load(object sender, EventArgs e)
{
if (IsLoaded())
{
this.LoadUserControl(controlUrl);
}
}
private void LoadUserControl(string code, bool update = false)
{
Ext.Net.Panel panel = this.pnlContainer;
if (update && currentUC != null)
{
panel.ContentControls.Clear();
}
currentUC = (UserControl)this.LoadControl(controlUrl);
currentUC.ID = "UC";
panel.ContentControls.Add(currentUC);
if (update)
{
panel.UpdateContent();
}
}
private bool IsLoaded()
{
return !string.IsNullOrEmpty(hdLoaded.Text);
}
protected void OnLoadControl(object sender, DirectEventArgs e)
{
this.LoadUserControl(controlUrl, true);
hdLoaded.Text = "loaded";
}
</script>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
<form id="form" runat="server">
<ext:ResourceManager runat="server" />
<ext:Hidden runat="server" ID="hdLoaded" />
<ext:Panel ID="pnlContainer" runat="server" Height="400" Width="400" Title="Containter">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button ID="btnX" runat="server" Text="Load" OnDirectClick="OnLoadControl" />
</Items>
</ext:Toolbar>
</TopBar>
</ext:Panel>
</form>
</body>
</html>
ExtUserControl.ascx
<%@ Control Language="C#" AutoEventWireup="true" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<script runat="server">
private Window _win;
private TextField _tf;
protected void Page_Load(object sender, EventArgs e)
{
BuildWindow();
}
[DirectMethod]
public void Show()
{
_win.Show();
}
private string GetId(string id)
{
return ID + id;
}
private void BuildWindow()
{
_win = new Ext.Net.Window { ID = GetId("myWin"), BodyPadding = 5, Border = false, Height = 300, Width = 300, Title = "Enter a value and press ClickMe", Hidden = true, Modal = true };
Ext.Net.Button button = new Ext.Net.Button { ID = GetId("btnWinAccept"), Text = "ClickMe", Icon = Icon.ApplicationError };
button.DirectEvents.Click.Event += WinClickAccept;
_win.Items.Add(button);
_tf = new TextField { ID = GetId("rfText") };
_win.Items.Add(_tf);
this.Controls.Add(_win);
}
private void WinClickAccept(object sender, DirectEventArgs e)
{
var txtResult = _tf.Text;
Ext.Net.X.MessageBox.Show(new MessageBoxConfig() { Title = string.Format(" InputValue = [{0}]", txtResult) });
_win.Close();
}
</script>
<ext:Button ID="Button1" runat="server" Text="ClickMe">
<Listeners>
<Click Handler="#{DirectMethods}.Show();" />
</Listeners>
</ext:Button>
When using this in the web.config I cannot get the Textfield value
<authentication mode="Forms">
<forms loginUrl="~/WebForm.aspx" />
</authentication>
<authorization>
</authorization>
Thanks,
Marc
Last edited by Daniil; Jun 08, 2015 at 10:17 AM.
Reason: [CLOSED]