Posted 11/29/2006 12:51:41 PM | | | | I have an EditPage with the standard Save, Save & Close, Save & New buttons in place, however, I need to add a custom button to this button bar. I have tried using the sample code provided in the SDK documentation but the page then throws the following error: System.InvalidCastException: Specified cast is not valid. The following is the line of code I have placed in the BuildMenuArea method to try and get the button to appear (no different than the example in the SDK, written in VB.NET). Instance.ButtonMenu.Items.Add(ControlFactory.CreateMenuItem("Test")) MyBase.BuildMenuArea()
Any suggestions or examples that might get this working? |
| Posted 12/4/2006 5:54:38 PM | | | | Bump? Can't figure out how to get this to work and need it for a client project. |
| Posted 12/5/2006 4:47:51 PM | | | I confirm that what you are describing is an issue in the SDK and has been reported as a defect. The problem is that the type of the ButtonMenu and the File menu as well are a type that is meant to be private instead of the public "Menu" type.
|
| Posted 2/23/2007 3:57:57 PM | | | This has been reported as defect number DE1474
|
| Posted 2/26/2007 11:49:45 AM | | | | Upon further investigation we discovered that this problem is bigger than I initially thought. The problem is that the interface exposed by the "Instance" property is in a private assembly and therefore it exposes types that were meant to be kept private, such as the private Menu. We had not noticed this problem before because 99% of the properties exposed by the page interfaces are standard .NET types such as string, datetime, HtmlForm, HtmlCell, etc. The type of the "ButtonMenu" and "FileMenu" on the EditPage interface are the only two exceptions were we attempt to expose c360 types via an interface. The right way to solve this problem would be to change the interface exposed by the "Instance" property on all the c360 page classes and make sure they are public and that they expose only public types. This would be a lot of work on our part and more importantly, it would break compatibility with your current custom solutions since the type of the Instance property would be changed. To fix this issue, you would simply need to recompile your solution and VS.NET would notice the change and link your custom solution to the appropriate type and assembly but I'm sure a lot of people would not appreciate that we introduce breaking changes. Our dev group is reloctant to make a change that would break backward compatibility in version 3. They would prefer to wait until version 4 since it will be a major upgrade anyway. This means that we need to find an alternative to fix this problem. I have a suggestion to work around this problem. It's an ugly solution, it's only a short term solution but I think it would allow us to achieve our goal of being able to add new buttons and menus items on the edit page: - I suggest that we add two new methods on the EditPage class called "AddFileMenuItem" and "AddButtonMenuItem" which would accept a menu item as input parameter and would append it to the corresponding menu.
- Since these two methods are not defined on the page interface, you would NOT be able to invoke them like this: "Instance.AddFileMenuItem(...);". You would have to bypass the interface and instead you would invoke them like this: "this.AddFileMenuItem(...);"
- This solution goes againt what our usual recommendation to use the "Instance" property in order to invoke methods and properties via the interface which is why I think this is an "ugly" solution and only a short-term "band-aid" but it gets the job done.
- When we release the SDK for version 4, we fix the problem like we should have done in the fist place which will allow you to invoke: "Instance.FileMenu.Items.Add(...);" and we mark the two new methods "AddFileMenuItem" and "AddButtonMenuItem" as obsolete.
Any thoughts?
|
| Posted 2/27/2007 6:35:19 PM | | | - I suggest that we add two new methods on the EditPage class called "AddFileMenuItem" and "AddButtonMenuItem" which would accept a menu item as input parameter and would append it to the corresponding menu.
Actually, I have an even simpler solution: no need to create two new methods, in 3.0.9 you will be able to use the following code: this.ButtonMenu.Items.Add(ControlFactory.CreateMenuItem("Testing", "MyImage.gif"));Notice that I am using "this" instead of "Instance" in order to work around the interface problem.
|
| |
|