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

    Bootstrap modal reopening when page refresh in asp.net

    Hi,

    i am using bootstrap model to display client infomation. i opening by link button and that
    button in gridview. and closing by modal closing button. But when our client refreshing /
    brower refreshing then again opening which he has opened previous bootstrap model to see
    client information. I want open bootstrap modal when client click link button not page refreshing
    or brower refresshing. i am using bootstrap modal closing with javascript :
    OnClientClick="$('#dMyActivityDetails').modal('hide'); return false;"


    aspx code :

    <asp:TemplateColumn HeaderText="Farmer Name" HeaderStyle-Width="10%">
    <ItemTemplate>
    <asp:LinkButton ID="lbFarmerName" runat="server" Text='<%#Eval("FARMER_NAME")%>'
    CommandName="Detail" ToolTip="View Farmer Detail's" Style="font-size: 11px; color: Blue;
    text-decoration: none;"></asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateColumn>

    <div id="dMyActivityDetails" class="modal fade" data-keyboard="false" data-backdrop="static">
    <div class="modal-dialog">
    <div class="modal-content">
    <div class="modal-header">
    <asp:Button ID="bClose1" runat="server" Style="float: right; color: White; font-weight: bold;"
    OnClientClick="$('#dMyActivityDetails').modal('hide'); return false;" aria-hidden="true"
    Text="x" class="btn btn-sm btn-info" />
    <h3 id="myModalLabel">
    View - Farmer Detail's</h3>
    </div>
    <div class="modal-body" style="max-height: 50%; margin-top: 05px; margin-bottom: 05px;">
    <asp:DetailsView ID="dVMyActivityDetail" runat="server" CssClass="table table-hover table-bordered table-striped"
    BackColor="White" ForeColor="Black" BorderStyle="Groove" AutoGenerateRows="False">
    <Fields>
    <asp:BoundField DataField="FARMER_NAME" HeaderText="Farmer Name" />
    <asp:BoundField DataField="AADHAR_CARD_NO" HeaderText="Aadhar Card No." />
    <asp:BoundField DataField="CONTACT_NO" HeaderText="Contact No" />
    <asp:BoundField DataField="EMAIL_ID" HeaderText="Email ID" />
    <asp:BoundField DataField="ADDRESS" HeaderText="Farmer Address" />
    <asp:BoundField DataField="SURVEY_NO" HeaderText="Survey No" />
    <asp:BoundField DataField="HISSA_NO" HeaderText="Hissa No" />
    <asp:BoundField DataField="GATH_NO" HeaderText="Gath No" />
    <asp:BoundField DataField="AREA" HeaderText="Area" />
    <asp:BoundField DataField="LAND_TYPE_NAME" HeaderText="Type Of Land" />
    <asp:BoundField DataField="LAND_FOR_NODE_NAME" HeaderText="Land for Node or R.O.W" />
    <asp:BoundField DataField="REGION" HeaderText="Region" />
    <asp:BoundField DataField="DISTRICT" HeaderText="District" />
    <asp:BoundField DataField="TAHSIL" HeaderText="Tahsil" />
    <asp:BoundField DataField="VILLAGE" HeaderText="Village" />
    <asp:BoundField DataField="STATUS" HeaderText="Stage" />
    <asp:BoundField DataField="STAGE" HeaderText="Status" />
    <asp:BoundField DataField="PRIORITY_STATUS" HeaderText="Priority" />
    </Fields>
    </asp:DetailsView>
    </div>
    <div class="well">
    <asp:Button ID="bClose" runat="server" class="btn btn-md btn-info" Text="Close"
    OnClientClick="$('#dMyActivityDetails').modal('hide'); return false;" />
    </div>
    </div>
    </div>
    </div>

    code behind :
    if (e.CommandName == "Detail")
    {
    lbFarmerDetail = (LinkButton)e.Item.FindControl("lbFarmerName");

    farmerEntity = new FarmerEntity();

    farmerEntity.ID = Convert.ToInt32(e.Item.Cells[(int)Column.ID].Text);

    farmerLogic = new FarmerLogic();

    sourceFarmer = farmerLogic.SelectFaramerDetail(farmerEntity);

    if (sourceFarmer.Rows.Count > 0)
    {
    dVMyActivityDetail.DataSource = sourceFarmer;
    dVMyActivityDetail.DataBind();

    ScriptManager.RegisterStartupScript(this, this.GetType(), "detailMsg", "$('#dMyActivityDetails').modal();", true);
    }

    }
  • #767313
    HI,
    Add this code so that modal will not open on Page Load()

    <script type="text/javascript">
    $(document).ready(function(){
    $('#dMyActivityDetails').modal('hide');
    });
    </script>


Sign In to post your comments