Full Postback from RadMenuItem

6 posts, 0 answers
  1. Mats
    Mats avatar
    66 posts
    Member since:
    Aug 2006

    Posted 18 Feb 2008 Link to this post

    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
  2. Steve
    Admin
    Steve avatar
    10940 posts

    Posted 20 Feb 2008 Link to this post

    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
  3. Mats
    Mats avatar
    66 posts
    Member since:
    Aug 2006

    Posted 20 Feb 2008 Link to this post

    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
  4. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 25 Feb 2008 Link to this post

    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
  5. Mats
    Mats avatar
    66 posts
    Member since:
    Aug 2006

    Posted 27 Feb 2008 Link to this post

    Hi!

    Your suggested solution works fine for me.

    Thanks
    /Mats
  6. Fredrik
    Fredrik avatar
    53 posts
    Member since:
    Oct 2007

    Posted 06 Feb 2009 Link to this post

    Ï 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
Back to Top