Sharepoint Forum

 
Home » Forum » Sharepoint       Ask a questionRSS Feeds

Postback Lifecycle Issue with MenuItem Captions

  Asked By: Keon Melendez         Date: Nov 27, 2005      Category: Sharepoint      Views: 234
 

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.

Tagged:            

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Postback Lifecycle Issue with MenuItem Captions Or get search suggestion and latest updates.


Your Answer
  • Answer should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].