Copied to clipboard

Flag this post as spam?

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


  • Jonathan Crosby 12 posts 33 karma points
    Apr 23, 2013 @ 00:00
    Jonathan Crosby
    0

    Include ASP control in Razor script

    Hi

    I would like to add the following asp login control to a razor script. It only displays the text and not the control. Apologies if this is an crazy question, I'm quite new to razor and Umbraco.

    @if(page.Login == true) 
    {
    <asp:Login ID=Login="Login1" runat="server"></asp:Login>
    }

    Would be quite amazing if someone can get this working.

  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 23, 2013 @ 06:55
    Fuji Kusaka
    0

    In razor you could do it this way

     var currentUser = Member.GetCurrentMember();
      if (currentUser!=null)
           {   
                  var userName = currentUser.Text;
                  var userLastName = currentUser.getProperty("lastName").Value.ToString();           
                 @userName @userLastName
           }
     

     

    //fuji

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 23, 2013 @ 18:30
    Tom Fulton
    0

    I don't think this will be possible really.  I've experimented with using @Html.Partial to render an ascx before, but Postback doesn't work, so kind of a moot point.  There's also an article here with some different methods, haven't looked into it though.  You could also wrap a usercontrol with your login form in a macro, and try using RenderMacro to render it, but I have a feeling postback won't work there either.

    Long story short, probably not worth the trouble.  If you're looking for a simple login form that'll work in Razor, check out the RazorLogin package, it works great :)

    -Tom

Please Sign in or register to post replies

Write your reply to:

Draft