2017-11-28 8 views
1

私の問題はラジオボタンリストを選択したときにモーダルウィンドウが閉じられることです。私はjavascriptの変更イベントを使用し、ポストバックasp rblのコントローラを使用しています。

実際、私のコード全体はupdatepanelの中​​にあります。この問題を防ぐ方法や方法を教えてください。

ありがとうございます。dopostbackからブートストラップ・モードを閉じるのを防ぐにはどうしたらいいですか?

javascriptの&のaspx

$('#<%=rbl.ClientID %> input').change(function() { 
 
    __doPostBack('<%: rbl.ClientID %>', ''); 
 
});
<asp:UpdatePanel runat="server" ID="panel"> 
 
    <ContentTemplate> 
 
    
 
    <div class="modal fade" id="Modal"> 
 
     <div class="modal-dialog"> 
 
     <div class='panel panel-info'> 
 
      <div class='panel-body'> 
 
      <asp:RadioButtonList ID="rbl" runat="server"> 
 
       <asp:ListItem Value="add">Add</asp:ListItem> 
 
       <asp:ListItem Value="remove">Remove</asp:ListItem> 
 
      </asp:RadioButtonList> 
 
      </div> 
 
     </div> 
 
     </div>   
 
    </div>        
 
    
 
    </ContentTemplate> 
 
</asp:UpdatePanel>

aspx.vb

Private Sub rbl_SelectedIndexChanged(sender As Object, e As EventArgs) Handles rbl.SelectedIndexChanged 
    myFnc() 
End Sub 
+0

[JSFiddle](https://jsfiddle.net/jcu1r83n/)を参照してください! – Pedram

答えて

2

あなたは以下のようにそれを行うことができます。

<div class="modal fade" id="Modal"> 
    <div class="modal-dialog"> 
     <asp:UpdatePanel runat="server" ID="panel"> 
      <ContentTemplate> 
       <div class='panel panel-info'> 
        <div class='panel-body'> 
         <asp:RadioButtonList ID="rbl" runat="server" OnSelectedIndexChanged="rbl_SelectedIndexChanged"> 
          <asp:ListItem Value="add">Add</asp:ListItem> 
          <asp:ListItem Value="remove">Remove</asp:ListItem> 
         </asp:RadioButtonList> 
        </div> 
       </div> 
      </ContentTemplate> 
     </asp:UpdatePanel> 
    </div> 
</div> 
0

同じ機能を実現するには、AutopostプロパティをTrueに設定してRadioButtonListのOnSelectedIndexChangedサーバーサイドイベントを使用できます。あなたはそれが以下のように必要な変更を行うと、この

   `<asp:RadioButtonList ID="rbl" runat="server" OnSelectedIndexChanged="rbl_SelectedIndexChanged(event)"> 
         <asp:ListItem Value="add">Add</asp:ListItem> 
         <asp:ListItem Value="remove">Remove</asp:ListItem></asp:RadioButtonList>` 

のようにイベントを渡す「OnSelectedIndexChanged」で

$('#<%=rbl.ClientID %> input').change(function() { 
    __doPostBack('<%: rbl.ClientID %>', ''); 
}); 
0

バック__doPostBackによる火災ポストする必要はありません。

`$('#<%=rbl.ClientID %> input').change(function (event) { 

__doPostBack( '<%:rbl.ClientID%>'、 '')。 event.preventDefault(); }) ` あなたのモーダルポップアップは閉じられません。

関連する問題