Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Christian Liebe-Harkort 56 posts 104 karma points
    Feb 15, 2010 @ 18:45
    Christian Liebe-Harkort
    0

    Pages do not postback with loginview on it

    Hi there,

    if I put a loginview on my mastertemplate the pages do not postback anymore.

    My LoginView is rather basic and works without problems in a non umbraco environment.


    <asp:LoginView ID="LoginView" runat="server">
    <AnonymousTemplate>
    Welcome Guest [
    <asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl="/login.aspx">Login</asp:LinkButton> ]<br />
    <asp:LinkButton ID="LinkButton2" runat="server" PostBackUrl="createuser.aspx">Or create a new account</asp:LinkButton>
    </AnonymousTemplate>
    <LoggedInTemplate>
    Welcome back <asp:LoginName ID="LoginName1" runat="server" /><br />
    <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutText="Log out now" />
    </LoggedInTemplate>
    </asp:LoginView>

     
     
     Whatever controls I have on my page, as soon as I put the LoginView on the masterpage. No more postbacks!
     
     Also tried to create a User Control with the LoginView on it, but that has the same effect.
     
     Why is that and what can I do?
     I am using umbraco v 4.0.2.1 (Assembly version: 1.0.3441.17657)
     
     thanks
     
     Christian

  • Matt Linsenbardt 11 posts 53 karma points
    Feb 15, 2010 @ 18:52
    Matt Linsenbardt
    0

    Hi Christian,

    Are you including <form runat="server"> tags in your master page?

  • Chris Koiak 700 posts 2626 karma points
    Feb 15, 2010 @ 18:57
    Chris Koiak
    0

    What do you mean 'no more postbacks'? Do the buttons work but result in Page.Ispostback = false?

    Check your markup structure and make sure you don't have any nested <form> tags. Does your markup validate?

    Cheers,

    Chris

  • Christian Liebe-Harkort 56 posts 104 karma points
    Feb 15, 2010 @ 19:14
    Christian Liebe-Harkort
    0

    Hi,

    my mastertemplate looks like:

    ......
    </head>
    <body>
        <form id="MasterForm" runat="server">
    .......

       
    This is the only form tag I have in the masterpages. (All other masterpages inherit from that page)


    With the pages not posting back anymore I mean, that a control on a page that worked before stops to postback.

    E.g.: A simple HelloWorld Example that postsback the value of a textbox like:


        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
            Literal1.Text = "Hello " + TextBox1.Text
        End Sub

    after I have the LoginView on the page and you click Button1, the page reloads, but the content of the textbox is erased and the Literal.text is empty.

    Christian

  • Chris Koiak 700 posts 2626 karma points
    Feb 15, 2010 @ 21:23
    Chris Koiak
    0

    I have no idea why this isn't working. LinkButton requires Javascript to be enabled is this enabled? If not, could you use a standard <a> tag instead?

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Feb 15, 2010 @ 21:49
    Morten Bock
    0

    I actually had that exact problem on a site a couple of weeks ago. The linkbutton control somehow breaks the postback of a site. It forces the form to render the old doPostback javascript stuff, and that somehow breaks the postback.

    My solution was to not use the linkbutton at all. As far as I can tell, you can just use regular links like Chris suggests. 

  • Matt Linsenbardt 11 posts 53 karma points
    Feb 15, 2010 @ 23:13
    Matt Linsenbardt
    0

    I'm using a link button inside of a usercontrol just fine with post back.

  • Chris Koiak 700 posts 2626 karma points
    Feb 15, 2010 @ 23:18
    Chris Koiak
    0

    Using <a> tags rather than a LinkButton also removes an unrequired dependency on JavaScript.

  • Christian Liebe-Harkort 56 posts 104 karma points
    Feb 16, 2010 @ 09:59
    Christian Liebe-Harkort
    0

    thanks for all the replies.

    replacing the LinkButton with <a> "solved" the problem, but  I am still wondering why and are there other ASP controls that should not be used?

    I find it also strange, that this works without problems in a non umbraco setup.

     

  • stc 72 posts 101 karma points
    Apr 14, 2010 @ 13:59
    stc
    0

    Any other solution to this problem plz?!

    I have a loginview and as I've noticed it takes two attempts to login to for the loginview to change the rendered template. (or one attempt and just open the same url in another tab inside the same browser instance)

    I can not use simple <a> tag because it lacks the code-behind click event handling which I desperately need.

    TIA all

     

     

  • stc 72 posts 101 karma points
    Apr 14, 2010 @ 14:57
    stc
    0

    solved it...kinda...caused a programmatic response.redirect to request.rawurl on a button that initiates login inside the loginview control...should that be the way...honestly don't know?!?

  • Ricardo 24 posts 56 karma points
    Apr 06, 2011 @ 14:05
    Ricardo
    0

    I have the similar problem with an ImageButton, it does not call the OnClick code behind after a postback.

    First time ASP.NET generates on page the usual function

          function __doPostBack(eventTarget, eventArgument) { ... }

    But after posting back page does not generate this so button code behind is not called.

     

Please Sign in or register to post replies

Write your reply to:

Draft