Copied to clipboard

Flag this post as spam?

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


  • Harald Ulriksen 207 posts 249 karma points
    Mar 21, 2011 @ 09:28
    Harald Ulriksen
    0

    Umbraco.Forms.Core.RecordField.CreateFromPage throws Object reference not set exception

    This happens on a hidden field.

       at Umbraco.Forms.Core.Providers.FieldTypes.HiddenField.get_Values() in d:\TeamCity6\buildAgent\work\278191fcc80f7b16\Umbraco.Forms.Core\Providers\FieldTypes\HiddenField.cs:line 63
       at Umbraco.Forms.Core.RecordField.CreateFromPage(Page page, Record record) in d:\TeamCity6\buildAgent\work\278191fcc80f7b16\Umbraco.Forms.Core\RecordField.cs:line 151
       at BSessions.GroupWeb.UserControls.InvitationImport.Button1_Click(Object sender, EventArgs e) in C:\sourcecode\GroupWeb\BSessions.GroupWeb\UserControls\InvitationImport.ascx.cs:line 114
       at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    Here's the code 

    Record record = Umbraco.Forms.Core.Record.Create();
    
    record.Created = DateTime.Now;
    record.UmbracoPageId = umbraco.presentation.UmbracoContext.Current.PageId.Value;
    record.IP = Request.UserHostAddress;
    record.Form = form.Id;
    record.CurrentPage = form.Pages[0].Id;
    record.MemberKey = umbraco.cms.businesslogic.member.Member.GetCurrentMember().Id;
    
    store.InsertRecord(record, form);
    
    List<RecordField> fields = Umbraco.Forms.Core.RecordField.CreateFromPage(form.Pages[0], record); 


    Is CreateFromPage deprecated, i.e. I should create every single field manually or is it something wrong with the hidden field? 

    If I'm not supposed to use CreateFromPage I would very much like to see an example on how this should be done.

    Thanks,
    Harald

  • Comment author was deleted

    Mar 22, 2011 @ 09:20

    @Harald,

    And if you remove the hidden field does it work ok then? If so looks like it's a bug with the hidden field, let me know and I'll fix it this week.

    Cheers,
    Tim

  • Harald Ulriksen 207 posts 249 karma points
    Mar 22, 2011 @ 09:26
    Harald Ulriksen
    0

    Hi Tim,

    yes. Seems to work just fine if I change the hidden field to a textstring. It's no hurry though, I had code for creating each field manually in another project.

    H.

Please Sign in or register to post replies

Write your reply to:

Draft