I am able to hide one of the buttons (coming and clear) when the member click on one of the buttons.
protected void setStatus(object sender, CommandEventArgs e)
{
Node n = Node.GetCurrent();
Member m = Member.GetCurrentMember();
clear.Visible = true;
coming.Visible = false;
if (e.CommandArgument == "coming")
{
Helper.RelateMemberToEvent(m.Id, n.Id, m.Text + " can come to " + n.Name);
EventStatuslbl.Text = "Du er nu tilmeldt eventen.";
}
else
{
Helper.DeclineComingToEvent(m.Id, n.Id, m.Text + " declined coming to " + n.Name);
}
}
protected void clearRelations(object sender, EventArgs e)
{
Node n = Node.GetCurrent();
Member m = Member.GetCurrentMember();
clear.Visible = false;
coming.Visible = true;
Helper.ClearRelations(m.Id, n.Id);
EventStatuslbl.Text = "Du er nu fjernet fra eventen.";
}
I also want that the clear button isn't visible if the member isn't related to the event... and the coming button isn't visible if the member already is signed up for the event.
Just like I have when the member click on one of the buttons and a message is shown in the label EventStatuslbl. So I need somehow on page load to get if the member is signed up or not.
Not sure here for the given situation, but maybe you can use the Relation.IsRelated() method to see if the current member is related to a specific event? :-)
- Bo
Taken from Hendy Rachers blog: bool isRelated = Relation.IsRelated(document.Id, member.Id, RelationType);
but there in something wrong or missing.. I have tried with LoadStatus(eventId, memberId); and LoadStatus(int eventId, int memberId); as well, but still marks it as an error..
Well, I think it's because the LoadStatus function need eventId and memberId.. but when a use them.. they are not defined in that codebehind.. but in the Helper.cs file..
LoadStatus() <--- No overload for method 'LoadStatus' takes 0 arguments LoadStatus(eventId, memberId) <--- The 'eventId' does not exist in the current context (the same with memberId)
In the Helper class is has:
public static void RelateMemberToEvent(int memberId, int eventId, string comment)
{
if (!Relation.IsRelated(eventId, memberId))
{
RelationType rt = RelationType.GetByAlias(_coming);
Relation.MakeNew(eventId, memberId, rt, comment);
}
}
Where in relate the member to the event if the member isn't already related.
How can I use this in page load method? so when the page is loaded it has hidden a button if the member in related to the event... if not it shows the button..
Anyone who knows how I can use the Relation.IsRelated to check if a event/node and member is related on page load? and the do something if it's related.. e.g. displays a message in a label.
Show/hide button if member is/is not related to event
Hi..
I have a event signup, where members are able to signup for events, where I have used the code from this video: http://umbraco.com/help-and-support/video-tutorials/developing-with-umbraco/relations/event-signup-with-relations
I am able to hide one of the buttons (coming and clear) when the member click on one of the buttons.
I also want that the clear button isn't visible if the member isn't related to the event... and the coming button isn't visible if the member already is signed up for the event.
Just like I have when the member click on one of the buttons and a message is shown in the label EventStatuslbl.
So I need somehow on page load to get if the member is signed up or not.
Bjarne
Hi Bjarne,
Not sure here for the given situation, but maybe you can use the Relation.IsRelated() method to see if the current member is related to a specific event? :-)
- Bo
Taken from Hendy Rachers blog: bool isRelated = Relation.IsRelated(document.Id, member.Id, RelationType);
Hi Bo
Yes, I have thought about something like that.. and create a function that should run on page load.
It has a Helper class that perhaps can be used to get if a member is related or not... I'm not sure how and where to write this..
Bjarne
I have tried with this:
and then in pageload:
but there in something wrong or missing.. I have tried with LoadStatus(eventId, memberId); and LoadStatus(int eventId, int memberId); as well, but still marks it as an error..
Bjarne
Hi Bjarne,
What does the error tell you? :-)
Well, I think it's because the LoadStatus function need eventId and memberId.. but when a use them.. they are not defined in that codebehind.. but in the Helper.cs file..
LoadStatus() <--- No overload for method 'LoadStatus' takes 0 arguments
LoadStatus(eventId, memberId) <--- The 'eventId' does not exist in the current context (the same with memberId)
In the Helper class is has:
Where in relate the member to the event if the member isn't already related.
Bjarne
I have seen some places to check of a member is related, e.g. here: http://blog.hendyracher.co.uk/umbraco-relation-api/
How can I use this in page load method? so when the page is loaded it has hidden a button if the member in related to the event... if not it shows the button..
Bjarne
Anyone who knows how I can use the Relation.IsRelated to check if a event/node and member is related on page load? and the do something if it's related.. e.g. displays a message in a label.
Bjarne
is working on a reply...