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

Full Postback from RadMenuItem

5 Answers 283 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Mats
Top achievements
Rank 1
Mats asked on 18 Feb 2008, 02:57 PM
Hi!

I have a RadContextMenu with several RadMenuItems in an Ajax UpdatePanel.
For some of the menu items I need to perform a full Postback (but not for all).

The most obvious way for me to do that is to use RegisterPostBackControl on the RadMenuItem: 
ScriptManager.GetCurrent(Page).RegisterPostBackControl(this.RadContextMenu1.Items[0]);

This doesn't seem to work on a RadMenuItem.
The postback is performed but the expected behaviour (exporting a radgrid to Word) is not done. Instead the text "509|updatePanel|RadContextMenu1Panel|MenuItem1MenuItem2|" is rendered.
 
If I register the contextmenu instead it works but then all menu items will perform a postback:
ScriptManager.GetCurrent(Page).RegisterPostBackControl(this.RadContextMenu1);

Any suggestions on how to solve this?

Thanks
/Mats

5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 20 Feb 2008, 01:49 PM
Hi Mats,

Please review the following code library. In the last post I've prepared a sample project to show you how this can be achieved.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mats
Top achievements
Rank 1
answered on 20 Feb 2008, 04:34 PM
Hi Steve!

I guess that you are refering to your sample project called ExportFromContextRadMenu.zip.

In that sample you are using RadAjaxManager. In my application i use Ajax UpdatePanel so I guess that I can't use your solution.

Regards
/Mats
0
Veselin Vasilev
Telerik team
answered on 25 Feb 2008, 08:42 AM
Hi Mats,

To overcome the problem you can try the following approach:

  • Add a button in a hidden <div> placed outside of the updatePanel on the page:
<div style="display: none;"
  <asp:Button ID="exportButton" runat="server" Text="PostBack" OnClick="exportButton_Click"></asp:Button> 
</div> 
  • Define the OnClientItemClicking event handler:
<script type="text/javascript"
function onClientItemClicking(sender, eventArgs) 
    if (eventArgs.get_item().get_text() == "Export"
    { 
        $get("exportButton").click(); //full postback
    } 
</script> 
  • In the code behind do the necessary action in the exportButton_Click event handler.

I hope this helps.

Best wishes,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mats
Top achievements
Rank 1
answered on 27 Feb 2008, 03:50 PM
Hi!

Your suggested solution works fine for me.

Thanks
/Mats
0
Mikael
Top achievements
Rank 1
answered on 06 Feb 2009, 03:59 PM
Ï am having the exact same problem, but the workaround for me seems really awkward. Can you provide some more information on why a RadMenuItem doesn't work as a trigger? Even better, is there a more elegant work-around?

Thanks!
/Fredrik
Tags
Menu
Asked by
Mats
Top achievements
Rank 1
Answers by
Steve
Telerik team
Mats
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Mikael
Top achievements
Rank 1
Share this question
or