This is a migrated thread and some comments may be shown as answers.

FormatException after clicking menu item

2 Answers 46 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 02 Jul 2010, 04:44 PM

Hello,

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:

 
aspx:

 

 

 

 

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


code-behind:

                RadMenuItem effectiveDateItem = new RadMenuItem(  
                    "Current",  
                    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;  
 
                effectiveDateItem.Items.Add(clearEffectiveDateItem);  
                base.ActionMenu.Items.Add(effectiveDateItem);  
 

Thanks for any help.

2 Answers, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 06 Jul 2010, 08:09 PM
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  
 
   
 
0
James
Top achievements
Rank 1
answered on 07 Jul 2010, 06:30 PM
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.
Tags
Menu
Asked by
Steve
Top achievements
Rank 1
Answers by
James
Top achievements
Rank 1
Share this question
or