0

I'm having some problems to bring my UpdatePanel to work properly.
I have all the menu-links in a control, of which the Login/Logout-links are dynamically displayed whether you are about to

  • Login
  • Login on 1 specific site in the whole project
  • Logout

HTML-Part:

<asp:UpdatePanel ID="upd_Login" runat="server">
    <ContentTemplate>
        <asp:PlaceHolder ID="plh_LoginOut" runat="server">
    </ContentTemplate>
</asp:UpdatePanel>

C#:

// Login/Logout-Link
#region Login
// Clear control
plh_LoginOut.Controls.Clear();
// Logout
if (Request.IsAuthenticated)
{
    // Add link to the placeholder
    HyperLink lnk_Logout = new HyperLink() { NavigateUrl = ResourceManager.GetString("logout.aspx"), Text = "{#logout#}" };
    plh_LoginOut.Controls.Add(lnk_Logout);
}
// Login
else
{
    // Session-Fix for the firm.aspx-Page
    if (Request.Url.AbsolutePath.ToLower().Contains("firma.aspx"))
    {
        // Add linkbutton to the placeholder
        LinkButton lbtn_Login = new LinkButton() { Text = "{#login#}", CssClass = "loginlink" };
        lbtn_Login.Click += new EventHandler(lbtn_Login_Click);
        plh_LoginOut.Controls.Add(lbtn_Login);
    }
    // Standard Logout-link
    else
    {
        // Add link to the placeholder
        HyperLink lnk_Logout = new HyperLink() { Text = "{#login#}", CssClass = "loginlink" };
        lnk_Logout.Attributes["onclick"] = "ShowLogin(true)";
        plh_LoginOut.Controls.Add(lnk_Logout);
    }
}
#endregion

This takes all place in a control (.ascx) which is directly embedded in the mastersite. (Scriptmanager is there as well). Now somehow, in the case of the Linkbutton-Logout-PostBack, the Page really reloads itself (so the Updatepanel does nothing).

Did I forget something or is this an error of some other kind?
Thank you very much for your help

2
  • Just a comment, but why not use the LoginView control to determine what is visible to logged in/anonymous users?
    – DavidG
    Nov 27, 2014 at 13:44
  • Hey David, I think it's mainly because I'm really new into the current project (running since ~12 years and I'm half a year here) and I never really gotten into the loginview so I thought I make it the best I could (since the whole project is one big mess)
    – Simon
    Nov 27, 2014 at 13:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.