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
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.
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.
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.
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?
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) {
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"
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 ;)
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.
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
Hello m
The source should be available here: http://umbnewsletter.codeplex.com/SourceControl/list/changesets - Is this what you're looking for?
/Jan
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
is there any possibility of help regarding the ascx files that need compiling?
regards / Marcus
Hi Marcus
What is it exatcly you're in doubt about?
I suppose you know your way around visual studio, or?
/Jan
Im getting alot of compiler-errors when trying to compile, perhaps you could post the code-behind code here?
/ Marcus
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
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.
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
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
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
yes, that was the problem partially. thank you!
/ MArcus
Partially? Any other problems?
In anycase, glad to have been the one helping instead of the one receiving help ;)
-Ferdy
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
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
is working on a reply...