I want to use a custom property to set the caption for a Web Part
MenuItem. Of course, the new value for the custom property is not
available in the CreateWebPartMenu method so I need to set the MenuItem
caption in RenderWebPart. But it seems that the Web Part Menu may be
unalterable in RenderWebPart. The MenuItem I want to set is a custom
one, but setting the caption doesn't even work for altering the built-in
MenuItems.
To see what I mean, drop this code at the beginning of your
RenderWebPart method in any existing C# Web Part (before the
base.RenderWebPart() statement):
WebPartMenu.MenuItems.ItemFromID("MSOMenu_Minimize").Caption =
"Altered Minimize Caption";
It simply sets the Minimize caption to a static value. Check out the
_unchanged_ Web Part menu in the browser. This code works fine in the
CreateWebPartMenu method, why not in the RenderWebPart method? Anyone
have any ideas on how to overcome this hairy postback lifecycle problem?
Do you know someone who can help? Share a link to this thread on twitter, or facebook.