locked
Input string was not in a correct format RRS feed

  • Question

  • I'm having some intermittent trouble with an editform that I have heavily customized.  I think I have it narrowed down to the offending part but I'm stuck on how to fix it.

    My page is an editform with tabs created from here: http://www.sharepointchamps.com/?p=21#more-21
    And a cascading dropdown menu (which I think is the problem) created from here: http://mdasblog.wordpress.com/2009/07/14/cascading-columns-in-a-sharepoint-form/

    Intermittently, when I access the form and either hit OK or Edit Page I get the following error:

    Server Error in '/' Application.
    --------------------------------------------------------------------------------
    
    Input string was not in a correct format. 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.FormatException: Input string was not in a correct format.
    
    Source Error: 
    
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
    
    Stack Trace: 
    
    
    [FormatException: Input string was not in a correct format.]
       System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +10159299
       System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +207
       System.Convert.ToInt32(String value, IFormatProvider provider) +55
       Microsoft.SharePoint.WebControls.ItemHiddenVersion.OnLoad(EventArgs e) +439
       System.Web.UI.Control.LoadRecursive() +66
       System.Web.UI.Control.LoadRecursive() +191
       System.Web.UI.Control.LoadRecursive() +191
       System.Web.UI.Control.LoadRecursive() +191
       System.Web.UI.Control.LoadRecursive() +191
       System.Web.UI.Control.LoadRecursive() +191
       System.Web.UI.Control.LoadRecursive() +191
       System.Web.UI.Control.LoadRecursive() +191
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428
    
     
    
    
    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082 



    I found this posting here which looked like it was perfect: http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/ed33bbd4-a396-476e-b04e-88161dfbdac6

    I was hiding a DVWP with the IsVisible=False but, I changed this to True and am still having the same issue.  What's frustrating is that it's intermittent and I can't figure out what's triggering it.  Right now it's every other time I edit the item but yesterday I edited the item 50 times without it coming up.  Any help would be appreciated!
    Wednesday, September 2, 2009 1:37 PM

Answers

  • I don't know if it is relevant. However, I have heavily customized form before - and I noticed that this kind of error could be little "smart" of SharePoint Designer. What I have found was, when I open the customized form (with ton of XSLT), it added additional tag inside. It show fine in SPD, but have the same exception.

    To overcome this problem, I always open the original copy to start the editing and kind of redo. (Copy paste from modified form). Although, I am not very clear about the problem, but this step save my breath.
    Best regards, Riwut Libinuko SharePoint Architect, Singapore Microsoft MVP | SharePoint Server | Singapore | cakriwut@gmail.com **Please let me know if you need more information** Blog : http://blog.libinuko.com
    • Marked as answer by Chengyi Wu Friday, September 11, 2009 3:08 AM
    Wednesday, September 2, 2009 11:44 PM

All replies

  • The error is due to some code trying to convert a string into a number.  Can you confirm that the string can be converted to a number, ie the string contains a number.

    My SharePoint Blog - http://www.davehunter.co.uk/blog
    Wednesday, September 2, 2009 2:16 PM
  • The error is due to some code trying to convert a string into a number.  Can you confirm that the string can be converted to a number, ie the string contains a number.

    My SharePoint Blog - http://www.davehunter.co.uk/blog
    Im not sure what string it's trying to convert.  The scripts I'm using for the tabs and for the cascading menus (see links) don't have any code like that from what I can tell.  The rest of the form is just a bunch of form fields and a DVWP, all built-in SP functionality.
    Wednesday, September 2, 2009 3:28 PM
  • I don't know if it is relevant. However, I have heavily customized form before - and I noticed that this kind of error could be little "smart" of SharePoint Designer. What I have found was, when I open the customized form (with ton of XSLT), it added additional tag inside. It show fine in SPD, but have the same exception.

    To overcome this problem, I always open the original copy to start the editing and kind of redo. (Copy paste from modified form). Although, I am not very clear about the problem, but this step save my breath.
    Best regards, Riwut Libinuko SharePoint Architect, Singapore Microsoft MVP | SharePoint Server | Singapore | cakriwut@gmail.com **Please let me know if you need more information** Blog : http://blog.libinuko.com
    • Marked as answer by Chengyi Wu Friday, September 11, 2009 3:08 AM
    Wednesday, September 2, 2009 11:44 PM
  • Guys -

    I have the same problem as Mikey52, Do you guys solved the problem mentioned by mikey. Can you help me out with this?


    Chakri
    • Proposed as answer by Zoran Zlatanov Wednesday, November 4, 2009 5:17 PM
    • Unproposed as answer by Mike Walsh FIN Friday, April 29, 2011 6:43 AM
    Friday, October 23, 2009 4:39 PM
  • Open your customized page with SharePoint Designer and find the following line of code:

    <SharePoint:ItemHiddenVersion runat="server" ControlMode="Edit"/>

    Remove it and see what happens.
    I hope it will help you. It helped me.

    • Proposed as answer by Eric_Alexander Thursday, September 30, 2010 12:50 PM
    Wednesday, November 4, 2009 5:18 PM
  • Advised to do this (i.e. remove "ItemhiddenVersion" control) by MS support.  Did not work. Caused new error. "Failed to get value of the "Attachments" column from the "Attachments" field type control. See details in log.  Exception message: Guid should contain 32 digits with 4 dashes"  Only way to get rid of it was to delete altered form and recreate from copy.


    ERJ MCSD MCDBA
    • Edited by joeller Friday, November 12, 2010 3:12 PM clarification
    Thursday, October 21, 2010 7:39 PM
  • Advised to do this (ie. redo edit by copying code into new version of modified edit form) by MS Support.  Did not work.  Caused Javascript error Line 94 Char 5 Error 'undefined' is null or not an object Code: 0.  In the viewsource line 94 is the blank line before the following script block

    <script type="text/javascript">
    //<![CDATA[
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    function __doPostBack(eventTarget, eventArgument) {
        if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
            theForm.__EVENTTARGET.value = eventTarget;
            theForm.__EVENTARGUMENT.value = eventArgument;
            theForm.submit();
        }
    }
    //]]>
    </script>

    This Javascript is not ours.

    I had a 145 entry forum discussion trying to get help for this before making MSDN Support call.


    ERJ MCSD MCDBA
    • Edited by joeller Friday, November 12, 2010 3:14 PM clarification
    Thursday, October 21, 2010 7:45 PM
  • Above error caused by Javascrtipt error in looking for ID of element whose id SharePoint had changed by adding "generate-id" 

    Microsoft never did solve the problem.  They decided that it may be due to a failure to intialize a value used by the ItemHiddenVersion control.  They thought that this might be due to the fact we are calling the form from a javascript document.location.href = "EditFormName.aspx".  We found that when the page was refreshed when first opened, then everything worked fine.  So we wrote a javascript function to examine a query string parameter when the page was first called. If it was there then that parameter was removed from the query string and the form recalled.  This effectively does a refresh on load.  And after the refresh, the value is set.

    If you go to http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.itemhiddenversion(v=office.12).aspx

    You will find that each page of an edit form should have when rendered something like

    <input name="ctl00$PlaceHolderMain$ItemHiddenVersion$ctl00$owshiddenversion" type="HIDDEN" id="ctl00_PlaceHolderMain_ItemHiddenVersion_ctl00_owshiddenversion" value="2" />

    It says this is there because:

    If you examine the content of DefaultTemplates.ascx file, you will find the following RenderingTemplate control:


    <SharePoint:RenderingTemplate ID="ItemHiddenVersion" runat="server">
    <Template>
    <INPUT ID=owshiddenversion TYPE=HIDDEN NAME="owshiddenversion" runat="server"/>
    </Template>
    </SharePoint:RenderingTemplate>

    The RenderingTemplate class represents a hybrid Control-ITemplate control that holds a System.Web.UI.HtmlControls.HtmlInputHidden control in its template container. The HtmlInputHidden control embeds the version number in a nonvisible fashion within the list item form and it is sent each time the list item form is posted back to the server. This allows the HTML <input type=hidden> element, and of course its value, to be programmatically accessible on the server across postbacks

    So Microsoft was saying that in my case for some reason the value of the hidden imput thus created was not being set when the page opened and therefore when the this value was submitted to the ItemHiddenVersion class it through an error because it was getting a null not a number.

     


     

    ERJ MCSD MCDBA

    • Edited by joeller Friday, November 12, 2010 3:30 PM Addition.
    Tuesday, November 9, 2010 4:35 PM
  • Better late than never... my guess this is an edit form on a document library.  Leave the orginial list form web part in place, hide it.  Move your new data form web part OUTSIDE of the web part zone. 
    Friday, April 29, 2011 4:18 AM