You must Sign In to post a response.
  • Category: ASP.NET

    Why when I click Dropdown list bootstrap modal is closing

    i am using bootstrap modal and in modal i am using dropdownlist. But When
    i click dropdownlist the modal is going close. i could not complete my
    entry form.

    <asp:UpdatePanel ID="upMain" runat="server" UpdateMode="Conditional">
    <Triggers>
    <asp:PostBackTrigger ControlID="bSave" />
    <asp:PostBackTrigger ControlID="bNewComment" />
    <asp:PostBackTrigger ControlID="btnShowPopup" />
    <asp:PostBackTrigger ControlID="ddlEditTypeOfLand" />
    </Triggers>
    <ContentTemplate>
    <asp:Button ID="btnShowPopup" runat="server" Text="Open Modal" class="btn btn-primary btn-lg" />
    <div id="myModal" class="modal fade" data-backdrop="static" data-keyboard="false"
    role="dialog">
    <div class="modal-dialog">
    <div class="modal-content">
    <div class="modal-header">
    <h4 class="modal-title">
    Confirmation</h4>
    </div>
    <div class="modal-body">
    <div class="row">
    <div class="col-sm-6 form-group">
    <b>Comments</b>
    <asp:Button ID="bNewComment" CssClass="btn btn-info" Text="Add Comment" runat="server"
    OnClick="bNewComment_Click" OnClientClick="showComment();" />
    </div>
    </div>
    <div class="row" id="dComment" runat="server" style="display: none;">
    <div class="col-sm-6 form-group">
    <b>Comments</b>
    <asp:TextBox ID="tbComment" TextMode="MultiLine" Width="500px" runat="server" placeholder="Enter Comments.."
    class="form-control"></asp:TextBox>
    </div>
    </div>
    <div class="col-sm-5 form-group">
    <b>Type Of Land</b><span style="color: Red; font-weight: bolder; font-size: medium;">*</span>
    <asp:DropDownList ID="ddlEditTypeOfLand" AutoPostBack="true" runat="server" class="form-control"
    OnSelectedIndexChanged="ddlEditTypeOfLand_SelectedIndexChanged">
    <asp:ListItem Value="0" Selected="True"><---Select---></asp:ListItem>
    <asp:ListItem Value="1">Wasted Land</asp:ListItem>
    </asp:DropDownList>
    </div>
    </div>
    <div class="modal-footer">
    <asp:Button ID="bClose" runat="server" CssClass="btn btn-primary" data-dismiss="modal"
    Text="Close" />
    <asp:Button ID="bSave" runat="server" CssClass="btn btn-primary" Text="Save" OnClick="bSave_Click" />
    </div>
    </div>
    </div>
    </div>
    </ContentTemplate>
    </asp:UpdatePanel>

    Code behind
    =========
    protected void ddlEditTypeOfLand_SelectedIndexChanged(object sender, EventArgs e)
    {
    try
    {
    this.GetCustomerList();
    }
    catch (Exception ex)
    {
    throw ex;
    }
    }
  • #767008
    Hi,

    The problem is "PostBackTriggers" inside UpdatePanel in your design.

    Before work on this issue we should know the difference between PostBackTrigger and AsyncPostBackTrigger and when we use those.

    1. AsyncPostBackTrigger:

    The data will transacted without Full post back, for example if you want to bind data based on dropdown selection in that case we should use this.

    2.PostBackTrigger:

    In postbacktrigger, it is full postback where as in AsyncPostBackTrigger it is partial postback, for example if you want to upload file, in that case it should full post back then only file saved in server, if you are using AsyncPostBackTrigger(Partial postback) file won't saved in server.

    Now decide which control you want to use for binding the data based on dropdown selection.

    In your situation you are performing PostBackTriggers (Full PostBack), that is the reason control looses his action/ data.

    Hope you understood...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #767010
    Hi,

    1. Try placing your bootstrap modal outside update panel and just place dropdown inside it.
    2. Try placing this code:

    $('#ddlEditTypeOfLand').click(function(event){
    event.stopPropagation();
    });?


  • Sign In to post your comments