0

I have a jquery mobile panel like so:

<a href="#panel2"  class="ss-header-actions-language">
    <span class="ss-header-labels" id="ss-general-label">Language</span>
</a>

<div data-role = "panel" id = "panel2" data-display="overlay" data-position="right" data-swipe-close="false" >
    <asp:RadioButton ID="rdbEng1" AutoPostBack="true"   runat="server" Text="English"  GroupName="lang"   />
    <asp:RadioButton ID="rdbspan1"  AutoPostBack="true"   runat="server" Text="Español"  GroupName="lang"   />
    <asp:Button runat="server" Text="Submit" OnClick="Submit_Click"   />
</div>

I want the panel to close when the submit button is clicked. Right now, panel closes when I select any radio button inside the panel. I want the panel to stay open if the Radio button is clicked, but as soon as I click on submit button, I want the panel to close.

How can I achieve that. Any help will be highly appreciated.

Selim Yildiz
  • 5,254
  • 6
  • 18
  • 28
Anjali
  • 2,540
  • 7
  • 37
  • 77

1 Answers1

0

First you need to prevent postback to server, in order to do that set AutoPostBack="false" to RadioButton and you can change asp:Button to input.

Then according to JQuery Mobile Panel:

A panel can also be closed by calling the panel's close method directly.

So this should work:

<a href="#panel2" class="ss-header-actions-language">
    <span class="ss-header-labels" id="ss-general-label">Language</span>
</a>

<div data-role="panel" id="panel2" data-display="overlay" data-position="right" data-swipe-close="false">
    <asp:RadioButton ID="rdbEng1" AutoPostBack="false" runat="server" Text="English" GroupName="lang" />
    <asp:RadioButton ID="rdbspan1" AutoPostBack="false" runat="server" Text="Español" GroupName="lang" />
    <input type="button" onclick="ClosePanel();" name="Submit" value="Submit" />
</div>

<script type="text/javascript">
    function ClosePanel() {
        $("#panel2").panel("close");
    }
</script>
Selim Yildiz
  • 5,254
  • 6
  • 18
  • 28
  • Can I do this with autopostback=true for Radiobutton – Anjali Jul 29 '20 at 13:58
  • Yes but you should work more on it. Because of with autopostback=true when you select radio button the page is post back and reload again, so in that case you should consider close panel in page load at client side. – Selim Yildiz Jul 29 '20 at 14:22