Bootstrap modal reopening when page refresh in asp.net

Posted by Cpatil1000 under ASP.NET on 7/26/2016 | Points: 10 | Views : 353 | Status : [Member] | Replies : 3
Hi,

i am using bootstrap model to display client information. 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 :
  <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" />
</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>





Responses

Posted by: A2H on: 7/27/2016 [Member] [MVP] Silver | Points: 25

Up
0
Down
Try hiding the modal popup on page load and open the popup only on button click
Add the below code in your script section
$(function () {
$('#dMyActivityDetails').modal('hide');
});


Thanks,
A2H
My Blog

Cpatil1000, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Cpatil1000 on: 7/27/2016 [Member] Starter | Points: 25

Up
0
Down
hi,
i used this following function
$(function () {

$('#dMyActivityDetails').modal('hide');
});
It is getting trouble to open my bootstrap modal.
because i m opening my modal by code behind and this is link button in gridview. my question is once i close it should not
open by page regresh. it's open by link button of gridview.

modal open:
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('show');", true);
}

}


Cpatil1000, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A2H on: 7/27/2016 [Member] [MVP] Silver | Points: 25

Up
0
Down
Could you please provide some details on the issue you are facing. The code which I provided will hide the modal popup on page load.You should be able to open the pop on button click .

Thanks,
A2H
My Blog

Cpatil1000, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response