C# and New Line - InfoPath Dev
in

InfoPath Dev

C# and New Line

Last post 01-07-2013 05:41 AM by jaxkookie. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 01-03-2013 07:22 AM

    C# and New Line

    is there a way using code (C#) to update a field and insert a newline on a regular text field. I can concat data from the field each time I update, but cant figure out how to concat and insert the new line. I have done this before using rules, but I am interested if there is a way using code.

    thanks

    Kind regards,
    Larry
    Filed under:
  • 01-07-2013 05:41 AM In reply to

    Well I was able to solve this myself, using code and the newline XML file.

     

    public void UpdateCommentHist(XPN comment, XPN hist)
            {
                FormSupport fs = null;
                BWSharePoint BWsp = null;
                SetupSupport(ref fs, ref BWsp);

                XPN root = CreateNavigator();
                XPN errormessage = root.SelectSingleNode(xErrorMsg, NamespaceManager);
                try
                {
                   
                   XPN newline = DataSources["NewLine"].CreateNavigator().SelectSingleNode("/linebreaks/newLine", NamespaceManager);
            // query ds
                   DataSources["NewLine"].QueryConnection.Execute();

                    if (comment.Value != "")
                    {
      // create time stamp
                        string dt = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
                        hist.SetValue(newline.Value + dt + ": " + comment.Value + " *** " + hist.Value);
                        //comment.SetValue(string.Empty);
                    }
                    else
                    {
                        //hist.SetValue(string.Empty);
                    }
                }
                catch (Exception ex)
                {
                    LogServ.LogError(ErrCat.TraceError, StrHndlr.strHandleError(ex));
                    fs.DeleteNil(errormessage);
                    errormessage.SetValue(StrHndlr.strHandleError(ex));
                }
            }

    unfortunately this method did not fit my needs. The comment field needed to change (change event). if I entered comments then hit submit, it would not submit on first click, only on second click,  i did not like this. I actually went back to using rules on my submit button to accomplish this

    Kind regards,
    Larry
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.