FormatException after clicking menu item

3 posts, 0 answers
  1. Steve
    Steve avatar
    24 posts
    Member since:
    Jun 2010

    Posted 02 Jul 2010 Link to this post


    I have a page with a RadMenu on it.  Some of the menu items are getting created in the markup, and some are created in code-behind
    inside Page_Load().  Most of the menu items work fine.  One of the menu items, however, does not.  When I click on it, it performs
    a postback, and some time after Page_Load() is executed, I get the following error:

    [FormatException: Input string was not in a correct format.]
       System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7471479
       System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
       System.Convert.ToInt32(String value) +63
       Telerik.Web.UI.HierarchicalControlItemContainer.FindItemByHierarchicalIndex(String hierarchicalIndex) +213
       Telerik.Web.UI.RadMenu.RaisePostBackEvent(String nodeIndex) +44
       Telerik.Web.UI.RadMenu.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String nodeIndex) +39
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

    In debug mode, I have examined the contents of the menu within Page_Load() at the postback, and the menu items look correct to me.
    Can anyone tell me what I am doing wrong here?

    The following is the code for the menu creation in the aspx file and also the code-behind:






    <telerik:RadMenu ID="menuActions" runat="server" Font-Names="Arial" Skin="Windows7">  
            <telerik:RadMenuItem Value="delete" NavigateUrl="javascript:Delete();" Text="Delete" Enabled="false" /> 
            <telerik:RadMenuItem Value="save" NavigateUrl="javascript:Save();" Text="Save" Enabled="false" /> 


                    RadMenuItem effectiveDateItem = new RadMenuItem(  
                        string.Format("javascript:__doPostBack('{0}','{1}');"base.ActionMenu.UniqueID, WebUtils.ActionsMenuTags.ChangeListEffectiveDate));  
                        effectiveDateItem.Value = WebUtils.ActionsMenuTags.ChangeListEffectiveDate;  
                        effectiveDateItem.ImageUrl = ResolveUrl(WebUtils.ImageUrls.EditDate);  
                    RadMenuItem clearEffectiveDateItem = new RadMenuItem("Clear",  
                        string.Format("javascript:__doPostBack('{0}','{1}');"base.ActionMenu.UniqueID, WebUtils.ActionsMenuTags.ClearListEffectiveDate));  
                    clearEffectiveDateItem.Value = WebUtils.ActionsMenuTags.ClearListEffectiveDate;  

    Thanks for any help.

  2. James
    James avatar
    35 posts
    Member since:
    Apr 2010

    Posted 06 Jul 2010 Link to this post

    I have the exact same problem and same scenario.  A rad menu with some items created in the html and others added in the code behind.

    In my case the items created in the code-behind are added on pageload when the page is not a postback.  View state is enabled on the menu.

    The menu item that has a problem has the navigate url set to perform a javascript __doPostBack().

    The stack trace is:
    [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  
       Telerik.Web.UI.HierarchicalControlItemContainer.FindItemByHierarchicalIndex(String hierarchicalIndex) +167  
       Telerik.Web.UI.RadMenu.RaisePostBackEvent(String nodeIndex) +20  
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29  
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981  
  3. DevCraft R3 2016 release webinar banner
  4. James
    James avatar
    35 posts
    Member since:
    Apr 2010

    Posted 07 Jul 2010 Link to this post

    I found my problem.  I was using menu.UniqueID in the doPostBack method instead of menu.ClientID.  Once I changed this, it was working fine.
Back to Top