How to detect if user has submitted a form already?

I have various user polls which are displayed within my page template as Xforms (so they appear on every page). Once the currently logged in user has voted, I would like to display the results of the poll instead of the form. Can anybody point me to an example of how to detect if the current user has submitted a particular form please? I will also need to output some simple results (probably as an HTML bar graph), so any advice on the best way to do this would be appreciated. All I need is the number of votes per option, as my polls are very simple. I think XFormStatistics would be better for me than XFormPostings? However, is it true that both of these classes are deprecated in EPiServer 5? Many thanks, /\dam
Jun 18, 2007 11:24
Bumping this - can anyone help? Thanks, /\dam
Jun 20, 2007 17:40
This is how I managed to detect if the remote form had already been submitted. Any feedback appreciated! // (remoteFormPage is a custom property that links to another page which in turn contains a form, ie: we are fetching a form from another page) EPiServer.XForms.XForm thisForm = new EPiServer.XForms.XForm(); // create a new XForm object Guid thisGuid = new Guid(remoteFormPage.Property["MainXForm"].ToString()); // get the Guid of our target form thisForm = EPiServer.XForms.XForm.CreateInstance(thisGuid); // instantiate our XForm as a copy of the one our Guid points to bool bolVoted = false; string sMyVote=""; foreach (EPiServer.XForms.XFormData thisFormData in thisForm.GetPostedData()) { // for all votes if (thisFormData.Sid == CurrentUser.Sid){ // compare the voter's SID with our current user sMyVote = "On " + thisFormData.DatePosted + " you voted: " + thisFormData.GetValues().Get(0); // debug text bolVoted=true; // they've voted before! break; // no point continuing to check votes } }
Jun 25, 2007 17:13
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.