locked
Multiline Fields losing data upon Submission in CustomNewForm.aspx RRS feed

  • Question

  • I am hoping that someone else has had this issue or has a solution for it, but I am using our Sharepoint site as an Request Entry and Tracking tool where users can submit a request to be worked.  There are no files allowed to be attached to these requests, it is solely a data entry type of system.  It seems to be a rare and freak occurance but I have had two separate users submit a request and the two Multiline Fields on my CustomNewForm.aspx are lost during the submission process somehow.

    I know that the Multiline fields cannot be setup as Required fields, so on my form I have them setup as asp:TextBox and also have some Javascript setup against them to count the number of Characters (so users don't exceed 2000 characters).  In addition, I am also using a asp:RequiredFieldValidator against these fields so that when a user attempts to submit the form and these fields are blank, the submission process is halted and they are directed to the empty fields to populate them.  Just in case it helps, below is the code for the field and the Validator:

    Field code:

    <asp:TextBox runat="server" id="ff4{$Pos}" text="{@Description}" textmode="MultiLine" __designer:bind="{ddwrt:DataBind('i',concat('ff4',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Description')}" onKeyDown="textCounter(this,countdown1,2000);" onKeyUp="textCounter(this,countdown1,2000);" onPaste="textCounter(this,countdown1,2000);" Rows="6" Width="400px" Font-Names="Verdana" Font-Size="8pt" ToolTip="Detail Description" />

    Validator code:

    <asp:RequiredFieldValidator runat="server" ErrorMessage="You must specify a value for this required field." id="RequiredFieldValidator1" ControlToValidate="ff4_1" />

    Unfortunately, neither of the users that this issue occured for encountered any errors on their side, and there is nothing on the Sharepoint side (that I can see; p.s. I don't have Sharepoint Server, just Sharepoint and Sharepoint Designer 2007).  It just seems like in the submission process, these fields were omitted from being saved resulting in lost data.

    If anyone has any ideas or if they have encountered this issue within Sharepoint, please let me know.  So far we have been lucky that the users retained their data for these missing fields, but I fear that soon someone will not and they will be very upset.

    Let me know if you have any questions as well and I can see about updating this post to help clarify.  Thanks in advance!!


    • Edited by GopherKing Thursday, March 29, 2012 8:44 PM Code did not display ...
    Thursday, March 29, 2012 8:42 PM

Answers

  • Ok, so some more digging around and I have found a solution for this issue. 

    First, let me explain a little more detail on this issue.

    My form consists of Sharepoint FormFields and also ASP.NET fields.  Some of my Sharepoint FormFields are Required, which upon submitting my form, if they are blank the user is redirected back to the form and the Validator Text is displayed beneath/beside each field that they omitted.  I have Required Validator's on my ASP.NET Fields as well, which work if they are the only fields left blank.  The problem here is that when a Sharepoint FormField with a Required Field set is left blank, upon redirecting the user back to the form to fill in the missing fields, the ASP.NET fields are not saved. 

    I was able to verify this by filling out all my ASP.NET fields on my form and leaving all the Required Sharepoint FormFields blank upon submitting my form.  I was redirected back to the original form to fill out the missed Sharepoint FormFields and did see my data in the ASP.NET fields.  Upon the second submission and locating my new entry, I found the ASP.NET fields were blank.

    The best way to explain what is happening on the back end is that upon the first submission, the record is saved (temporarily) but only the Sharepoint Fields.  The ASP.NET fields are saved locally to the user, which is why the field retain their data upon being redirected back to the original form to fill in the missing fields, but upon the second submission, the data in the ASP.NET fields is lost.

    Now, the solution!!!

    So in my searching, I came across the following post:

    http://social.msdn.microsoft.com/forums/en-US/sharepointcustomization/thread/80712782-36fd-42d2-9c12-dd54768efa87

    In this post, there was advise of setting the EnableViewState on each of the ASP.NET fields to "FALSE".  I was a bit skeptical about this since there wasn't any difinitive reason why this works, but I tried it anyway.  It worked (at least in my situation)!!

    I even did a test where one of my ASP.NET fields was set with EnableViewState=True and the other set to EnableViewState=False.  The field set to "False" still retained it's data. 

    As I noted above, there was no reason given as to why this works, but I wanted to pass this on just in case it could be a solution for others.

    • Marked as answer by GopherKing Monday, April 2, 2012 2:24 PM
    Monday, April 2, 2012 2:24 PM

All replies

  •  

    Hi GopherKing,

    According to your description, I only give you some advice to ensure where is the wrong.

    1. First, delete your validator code, only use a simple multiple line text control.
    2. Second, if it is ok after step1, may be it is something wrong in your validator Control, if not, please remove some javascript event on your control.

    You can refer to the following link.

    http://www.codeproject.com/Articles/28212/Adding-Validation-to-a-Custom-List-Control-in-Shar

    Thanks,

    Jack

    Monday, April 2, 2012 11:36 AM
    Moderator
  • Hi Jack,

    Thanks for the suggestions, I will definitely give them a try.  The unfortunate thing about this is that I cannot recreate the issue, so this now becomes a waiting game for me ... I'll respond to this post if I find either one to work so that others can possibly benefit from it.

    Also, you mentioned removing some of the javascript events on my control, I wanted to also provide the actual javascript being run on each event, just in case you can see an issue in there.  Here is the code:

    function textCounter (field, count, maxLength) {
     if (field.value.length > maxLength) {
      alert("You have reached the " + field.title + " field maximum length of " + maxLength + " characters.");
      field.value = field.value.substr(0,maxLength);
      count.value = maxLength - field.value.length;
     } else {
      count.value = maxLength - field.value.length;
     }
    }

    Thanks.

    Monday, April 2, 2012 12:49 PM
  • Ok, so some more digging around and I have found a solution for this issue. 

    First, let me explain a little more detail on this issue.

    My form consists of Sharepoint FormFields and also ASP.NET fields.  Some of my Sharepoint FormFields are Required, which upon submitting my form, if they are blank the user is redirected back to the form and the Validator Text is displayed beneath/beside each field that they omitted.  I have Required Validator's on my ASP.NET Fields as well, which work if they are the only fields left blank.  The problem here is that when a Sharepoint FormField with a Required Field set is left blank, upon redirecting the user back to the form to fill in the missing fields, the ASP.NET fields are not saved. 

    I was able to verify this by filling out all my ASP.NET fields on my form and leaving all the Required Sharepoint FormFields blank upon submitting my form.  I was redirected back to the original form to fill out the missed Sharepoint FormFields and did see my data in the ASP.NET fields.  Upon the second submission and locating my new entry, I found the ASP.NET fields were blank.

    The best way to explain what is happening on the back end is that upon the first submission, the record is saved (temporarily) but only the Sharepoint Fields.  The ASP.NET fields are saved locally to the user, which is why the field retain their data upon being redirected back to the original form to fill in the missing fields, but upon the second submission, the data in the ASP.NET fields is lost.

    Now, the solution!!!

    So in my searching, I came across the following post:

    http://social.msdn.microsoft.com/forums/en-US/sharepointcustomization/thread/80712782-36fd-42d2-9c12-dd54768efa87

    In this post, there was advise of setting the EnableViewState on each of the ASP.NET fields to "FALSE".  I was a bit skeptical about this since there wasn't any difinitive reason why this works, but I tried it anyway.  It worked (at least in my situation)!!

    I even did a test where one of my ASP.NET fields was set with EnableViewState=True and the other set to EnableViewState=False.  The field set to "False" still retained it's data. 

    As I noted above, there was no reason given as to why this works, but I wanted to pass this on just in case it could be a solution for others.

    • Marked as answer by GopherKing Monday, April 2, 2012 2:24 PM
    Monday, April 2, 2012 2:24 PM