Copied to clipboard

Flag this post as spam?

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


  • Marcus 41 posts 61 karma points
    Feb 08, 2011 @ 20:39
    Marcus
    0

    installing and making subscription code behind files

    Hello!

     

    Im trying to get the member subscribe button and code behind to work. Could you provide me with the code-behind-files as i cant get it to work myself, much appreciated

     

    Regards / Marcus

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 08, 2011 @ 21:20
    Jan Skovgaard
    0

    Hello m

    The source should be available here: http://umbnewsletter.codeplex.com/SourceControl/list/changesets - Is this what you're looking for?

    /Jan

  • Marcus 41 posts 61 karma points
    Feb 10, 2011 @ 20:54
    Marcus
    0

    Hello!

    no, i meant i cant get the installation to work by following the documentation on how to make the subscribe button and txtfield and then compile the ascx file.

    / Marcus

  • Marcus 41 posts 61 karma points
    Feb 16, 2011 @ 13:57
    Marcus
    0

    is there any possibility of help regarding the ascx files that need compiling?

     

    regards / Marcus

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 16, 2011 @ 19:40
    Jan Skovgaard
    0

    Hi Marcus

    What is it exatcly you're in doubt about?

    I suppose you know your way around visual studio, or?

    /Jan

  • Marcus 41 posts 61 karma points
    Feb 17, 2011 @ 08:54
    Marcus
    0

    Im getting alot of compiler-errors when trying to compile, perhaps you could post the code-behind code here?

     

    / Marcus

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 17, 2011 @ 09:08
    Jan Skovgaard
    0

    Hi Marcus

    If you get the latests version of the source code from codeplex, isn't there a visual studio project you can just open and edit? I'm not a C# dev myself and I have nothing to do with the project...therefore my help may be sparse.

    But I think that it's the code from the "trunk" folder you need to modify and make sure you reference the correct umbraco .dll files.

    What kind of errors do you get by the way?

    /Jan

  • Ferdy Hoefakker 214 posts 248 karma points
    Feb 17, 2011 @ 09:51
    Ferdy Hoefakker
    0

    Hello Marcus,

    Are you making your own subscription page? Because as far as I'm aware, there is no such code in the package by default, but making one shouldn't be too difficult.

    protected void btnSave_Click(object sender, EventArgs e)
    {
    if (Member.GetMemberFromEmail(yourEmailTextBox.Text) == null)
    {
    MemberType mt = MemberType.GetByAlias("yourMemberTypeAlias");
    MemberGroup mg = MemberGroup.GetByName("yourMemberGroupName");

    Member newMember = Member.MakeNew(yourUsernameTextBox.Text, mt, new umbraco.BusinessLogic.User(0));

    newMember.Email = yourEmailTextBox.Text;
    newMember.Password = "dUy7Da7"; //random password here
    newMember.LoginName = yourUsernameTextBox.Text;
    newMember.AddGroup(mg.Id);

    newMember.Save();
    }
    else
    {
    //member exists
    }
    }

    That's the action linked to the save button on the form I made. If I misunderstood your request, my apologies, but I hope this helps. If it doesn't what sort of compiler errors are you getting?

    -Ferdy

  • Marcus 41 posts 61 karma points
    Feb 17, 2011 @ 11:33
    Marcus
    0

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Security;

    namespace Umbraco_Project1.usercontrols
    {
    public partial class NLSubscribe : System.Web.UI.UserControl
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSubscribe_Click(object sender, EventArgs e)
    {
    if (Member.GetMemberFromEmail(txtEmail.Text) == null)
    {
    MemberType mt = MemberType.GetByAlias("NewsletterType");
    MemberGroup mg = MemberGroup.GetByName("NewsletterGroup");
    Member newMember = Member.MakeNew(txtEmail.Text, mt, new umbraco.BusinessLogic.User(0));
    string password = Membership.GeneratePassword(7, 1);
    newMember.Email = txtEmail.Text;
    newMember.LoginName = txtEmail.Text;
    newMember.Password = password;
    newMember.AddGroup(mg.Id);
    newMember.Save();
    }
    }
    }
    }

     

     

    Errorcodes:

    Error 1 The name 'Member' does not exist in the current context d:\documents and settings\administratör\mina dokument\visual studio 2010\Projects\Umbraco Project1\Umbraco Project1\usercontrols\NLSubscribe.ascx.cs 20 21 Umbraco Project1
    Error 2 The type or namespace name 'MemberType' could not be found (are you missing a using directive or an assembly reference?) d:\documents and settings\administratör\mina dokument\visual studio 2010\Projects\Umbraco Project1\Umbraco Project1\usercontrols\NLSubscribe.ascx.cs 22 17 Umbraco Project1

     

    and a couple more errors, im sure you guys already know my problem :-) im still learning "trial and error style"

    Regards / Marcus

  • Ferdy Hoefakker 214 posts 248 karma points
    Feb 17, 2011 @ 12:04
    Ferdy Hoefakker
    0

    Ah, well, you're not referencing the umbraco dlls it seems.

    In your project, open the folder called "references" (or whatever it is called in your visual studio language)and make sure "Businesslogic" and "cms" are in that list. If they aren't, do the following (else skip this part):

    In your project, right click on the folder "references" and select "Add reference".

    Go to the tab "Browse"

    Browse to your umbraco folder and select the following dlls: Businesslogic.dll and cms.dll (those are the two you need I believe).

    Okay, you now added the references. If you have done (or already did that) you need to refer to them in your page by adding this "using" statement:

    "using umbraco.cms.businesslogic.member;" (with the " naturally)

    The posted error at the very least should be gone  then ;)

    Hope this helps!

    -Ferdy

  • Marcus 41 posts 61 karma points
    Feb 17, 2011 @ 13:01
    Marcus
    0

    yes, that was the problem partially. thank you!

     

    / MArcus

  • Ferdy Hoefakker 214 posts 248 karma points
    Feb 17, 2011 @ 13:10
    Ferdy Hoefakker
    0

    Partially? Any other problems?

    In anycase, glad to have been the one helping instead of the one receiving help ;)

    -Ferdy

  • Marcus 41 posts 61 karma points
    Feb 17, 2011 @ 14:45
    Marcus
    0

    well i had trouble compiling as it said "

    warning CS0618: 'umbraco.cms.businesslogic.member.Member.MakeNew(string, umbraco.cms.businesslogic.member.MemberType, umbraco.BusinessLogic.User)' is obsolete: 'Use System.Web.Security.Membership.CreateUser'"

    but it seemed to work with the old code "Member newMember = Member.MakeNew(txtEmail.Text, mt, new umbraco.BusinessLogic.User(0));"

    thank you all for the ideas that moved me towards the solution!

    / Marcus

  • Ferdy Hoefakker 214 posts 248 karma points
    Feb 17, 2011 @ 16:00
    Ferdy Hoefakker
    0

    Oh right, yeah. Warnings are just that, warnings. They alert you to possible issues, but the code can run just fine most of the time :P

    Anyways, yeah, I just realized the code I pasted is obsolete, you could try System.Web.Security.Membership.CreateUser(). It's technically better to use code that's not "obsolete" or "deprecated" since it might be removed in future updates.

    -Ferdy

Please Sign in or register to post replies

Write your reply to:

Draft