RadMenu is hiding on postback

3 posts, 0 answers
  1. Sharan
    Sharan avatar
    9 posts
    Member since:
    Jul 2012

    Posted 25 Nov 2013 Link to this post


    Hi Team

    I am using a RadMenu inside I have added RadMenuItems ie. CheckBox and RadCombobox.

    I am opening the menu onclick of menu using the property ClickToOpen="true".

    Now when I  change the RadCombox, page postbacks and bind the new values in other RadCombobox.

    When postback happens the RadMenu is hiding which I DONT WANT. I want to hide the postback only on the button Go which is also a part of RadMenu.

    Please can you please suggest how to prevent RadMenu to hide on Postbacks?

    Below is the code I am using...
    <telerik:RadMenu ID="RadMenu1" runat="server" Style="z-index: 2000" ClickToOpen="true" Visible="true"
                                            OnClientItemClosing="OnClientItemClosing">
                                            <items>
                                                <telerik:RadMenuItem Text="Card Filter">
                                                    <Items>
                                                        <telerik:RadMenuItem Text="CardFilter">
                                                            <ItemTemplate>
                                                                <table>
                                                                    <tr>
                                                                        <td colspan="2">
                                                                            <asp:CheckBox runat="server" ID="chkUseFleetFilter" Text="Use fleet filter for cards"
                                                                                Checked="true" AutoPostBack="true" Font-Names="Verdana" Font-Size="0.8em" OnCheckedChanged="chkUseFleetFilter_CheckedChanged" />
                                                                        </td>
                                                                        <td>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:RadioButtonList ID="radListDateTime" Enabled="true" runat="server" Font-Names="Verdana"
                                                                                Font-Size="0.8em">
                                                                                <asp:ListItem Text="Fleet" Value="Fleet" Selected="True" />
                                                                            </asp:RadioButtonList>
                                                                        </td>
                                                                        <td>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label ID="lblFleetLevel" runat="server" Width="100px" Text="Fleet Level"></asp:Label>
                                                                        </td>
                                                                        <td>
                                                                            <telerik:RadComboBox ID="ddlFleetLevel" runat="server" Width="200px" Enabled="false" OnSelectedIndexChanged="ddlFleetLevel_SelectedIndexChanged" AutoPostBack="true"
                                                                                OnClientDropDownOpening="OnClientDropDownOpening" OnClientDropDownClosed="OnClientDropDownClosed">
                                                                            </telerik:RadComboBox>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label ID="lblFleetItem" runat="server" Text="Fleet Item" Visible="false"></asp:Label>
                                                                        </td>
                                                                        <td>
                                                                            <telerik:RadComboBox ID="ddlFleetItem" runat="server" Width="200px" Enabled="false" Visible="false"
                                                                                OnClientDropDownOpening="OnClientDropDownOpening" OnClientDropDownClosed="OnClientDropDownClosed">                                                                          
                                                                            </telerik:RadComboBox>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label ID="lblFindCard" runat="server" Text="Find Card"></asp:Label>
                                                                        </td>
                                                                        <td>
                                                                            <telerik:RadTextBox ID="txtFindCard" runat="server" Width="200px" Enabled="false">
                                                                            </telerik:RadTextBox>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                        </td>
                                                                        <td align="left">
                                                                            <telerik:RadButton ID="btnGo" runat="server" Width="50px" Text="Go" ToolTip="Go"
                                                                                Enabled="false" />
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </ItemTemplate>
                                                        </telerik:RadMenuItem>
                                                    </Items>
                                                </telerik:RadMenuItem>
                                            </items>
                                        </telerik:RadMenu>


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Nov 2013 Link to this post

    Hi Sharan,

    The RadMenu items remain closed whenever a PostBack happens. One suggestion is that you can open the menu items by calling a client side function from the server side as shown below.

    C#:
    protected void ddlFleetLevel_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    {
        string menuItem = RadMenu1.SelectedItem.Text;
        string script = "function f(){openMenu('" + menuItem + "'); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
    }

    JavaScript:
    <script type="text/javascript">
        function openMenu(itemText) {
            $find("RadMenu1").findItemByText(itemText).open();
        }
    </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sharan
    Sharan avatar
    9 posts
    Member since:
    Jul 2012

    Posted 25 Nov 2013 Link to this post

    Thank you very much Shinu for quick reply..

    Its working as expected.

    Thanks
    Sharan
Back to Top