Sunday, March 11, 2012

LoginView and UpdatePanel

I have a similar problem also. I have placed a Login Control inside <anonymoustemplate> tag of LoginView Control . I am using the following code ... any help would be appreciated.

<%@.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

</head>

<body>

<formid="form1"runat="server">

<atlas:ScriptManagerID="ScriptManager1"EnablePartialRendering="true"runat="server"/>

<atlas:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<div>

<asp:LoginStatusID="LoginStatus1"runat="server"/>

<asp:LoginViewID="LoginView1"runat="server">

<LoggedInTemplate>

you are now logged in. Welcome<asp:LoginNameID="LoginName2"runat="server"/>

</LoggedInTemplate>

<AnonymousTemplate>

<asp:LoginID="Login1"runat="server"BackColor="#F7F6F3"BorderColor="#E6E2D8"BorderPadding="4"

BorderStyle="Solid"BorderWidth="1px"Font-Names="Verdana"Font-Size="0.8em"

ForeColor="#333333">

<TitleTextStyleBackColor="#5D7B9D"Font-Bold="True"Font-Size="0.9em"ForeColor="White"/>

<InstructionTextStyleFont-Italic="True"ForeColor="Black"/>

<TextBoxStyleFont-Size="0.8em"/>

<LoginButtonStyleBackColor="#FFFBFF"BorderColor="#CCCCCC"BorderStyle="Solid"BorderWidth="1px"

Font-Names="Verdana"Font-Size="0.8em"ForeColor="#284775"/>

</asp:Login>

</AnonymousTemplate>

</asp:LoginView>

</div>

</ContentTemplate>

</atlas:UpdatePanel>

</form>

<scripttype="text/xml-script">

<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">

<references>

</references>

<components>

</components>

</page>

</script>

</body>

</html>


From my efforts with this, it seems that the update panel can't exist inside any template container. Template controls are initiated differently than non templated controls (they have more of a late bound behavior), and the Atlas controls need to be instantiated early so that they are visible during the initcontrols process. That means that the Atlas controls won't work in LoginView, WizardPanels, or templates for the datasource objects.

In fairness to the folks developing Atlas, the template control limitation isn't exactly new. A good example of a similar issue is to attempt a FindControl() call to a control inside a template from a location outside the template. The standard control structure is broken, and you won't find the control.

I'm working on an Ajax/Atlas sample for a presentation I'm giving in a few weeks, and this seems to be substantial limitation to the Atlas project compared to other Ajax solutions. The less intrusive the solution, the more flexible it is in working with other components. I would recommend that the Atlas developers include Atlas containers that take advantage of 2.0 functionality like the login view, as well as an Atlas User Control container (Atlas controls in a user control don't render in the calling page, even if a script manager exists on the page) and possibly another page base that contains the script manager to solve rendering/usage issues based on limitations that they're introducing.


Hi all,

I know this is an old thread, but, I'm having the same problem here eith the March CTP. The LoginView control is placed inside the update panel (NOT the updatepanel inside a LoginView template) in a way similar to the code above. The templates were changing correctly before I put the whole LoginView control inside the UpdatePanel, and when I didn, it keeps showing me the anonymous template.

I tried this with both modes for UpdatePanel, "Always" and "Conditional". And of course I have forms authentication in web.config (it all work withoutt he UpdatePanel as I mentioned earlier).

Cny idea what may be casing this, and how to overcome it ?


Thanks, we'll look into this.

-Mike
howdy all.

regarding the 2 requests, i guess that it's easy to explaint. if i remember correctly, the login control will invoke a response.redirect which explains the fact that you're seeing a refresh of the page.

looking at the scriptmanager through reflector seems to show the bug: the scriptmanager class hooks up the presendrequestheaders event where it checks the statuscode of the response. it looks like that when issues a response.redirect call, the headers are removed (response.clearheaders is invoked) and due to that the cookie generated during the login event isn't sent to the client side.

these are the reasons that explain the behavior you're seeing when you put the login control inside the updatepanel.

to me it looks like this is a bug. where do you REPORT IT?

thanks.
>In fairness to the folks developing Atlas, the template controllimitation isn't exactly new. A good >example of a similar issue is toattempt a FindControl() call to a control inside a template from alocation >outside the template. The standard control structure isbroken, and you won't find the control.

Not sure if this helps, but I've been able to set the focus this way with a Login Control:

TextBox userName = (TextBox)Login1.FindControl("UserName");
Page.SetFocus(userName);

Hi. Any news about it? I need atlas to work in the loggedin template of the LoginView control, but if i surround it with the update panel, login won't log-me-in and it will refresh to the login page.

Sorry for my English and thanks for your answers.


hello.

as i pointed out earlier, currently you can't put the login control inside the udpatepanel since the set-cookie header won't be sent from the server side during an atlas postback. what you can do is perform the login manually (ie, without using the login control) or you can do it from the client side by using the atlas services.

The other work around would be to add a atlas timer control and do the redirect on the tick event

so instead of aredirect after the login just do a timer.enable == true

and on the timer_tick event do the redirect. You can set the tick to be 1. (not even noticable)

cheers!


hello. well, it's not a problem of the loginview. the problem is the login control. you see, when it validates the user, it adds a set-cookie header and performs a response.redirect. the problem is that the atlas platform intercepts the response.redirect on the server and when that happens it removes all the headers from the response (yes, there goes your set-cookie header). due to this, you wont have the form cookie that identifies a logged in user and you're allways going to have a loginview that shows the login control.
Hey,

I did a custom login using Atlas, that works but how do I promptly invoke the updatePanel to update the LoginView Component?

Hi

Is this still an issue? I seem to be able to login fine using LovinView inside an UpdatePanel, but can not prevent a page postback.

Is there a way to prevent the page posting back on login?

Thanks

Shaun

bryant:

Does the LoginView work with the UpdatePanel in the January CTP?

When I put the LoginView in the UpdatePanel it doesn't change when I login or logout (and the page seems to be refreshed).


To update the loginview I have a Timer with an interval of 100. This timer has enabled=false. It is also set as an asynch-trigger for the updatepanel. When I want to update the loginview, I enable the timer, which then updates the loginview on the next tick. In order to stop the timer again, I set the Timer's enabled property to false in the LoginView1_ViewChanged-event. This causes the Timer to only fire once and it is then disabled. Upon firing the timer, the loginview changes.

There might be a better solution, but this works for me


hello.

well, i'm not sure on what you're trying to do here. If i'm not mistaken, these problems have been solved in version 1.0 of the framework.

No comments:

Post a Comment