am having problem seting my frame src from code behind to use in my modal on button click.the frame src is getting the value but not displaying the page in the modal. the modal code
<div class="modal fade " id="modal-info" role="dialog" data-keyboard="false" style="border: none; height: 500px;" >
<div class="modal-dialog col-md-push-1">
<!-- Modal content-->
<div class="modal-content" style="width: 700px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Set Leave</h4>
</div>
<div class="modal-body">
<iframe id="frm" runat="server" width="96.6%" style="border: none; height: 300px;"></iframe>
</div>
<div class="modal-footer">
<button type="button" id="Button2" class="btn btn-primary" data-dismiss="modal" runat="server" onserverclick="close_ServerClick">OK</button>
</div>
</div>
</div>
</div>
then in code behind on button click
frm.Src = "../Popups/staff_leave_calender.aspx";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "$('#modal-info').modal();", true);
it only works only if the frame src in set on page load
protected void Page_Load(object sender, EventArgs e)
{
frameinfo.Src = "../Popups/staff_leave_calender.aspx";
}
and i needed to do something like
Session["leaveid"] = StrID;
frameinfo.Src = "../Popups/staff_leave_calender.aspx?lvv=" + StrID;
will use Str ID in the page loaded in modal.what are other options or what else can i do.
use it from javascript full code in your aspx file addd on top script as
<script type="text/javascript">
$(document).ready(function () {
/* Get iframe src attribute value i.e. YouTube video url
and store it in a variable */
var url = "../Popups/staff_leave_calender.aspx?lvv="+"<%= Session["leaveid"].ToString() %>";
/* Assign empty url value to the iframe src attribute when
modal hide, which stop the video playing */
document.getElementById("<%= btnAlelrt.ClientID %>").on('hide.bs.modal', function () {
$("#frm").attr('src', '');
});
/* Assign the initially stored url back to the iframe src
attribute when modal is displayed again */
document.getElementById("<%= btnAlelrt.ClientID %>").on('show.bs.modal', function () {
$("#frm").attr('src', url);
});
});
</script>
and in code behind file create the session leaveid if it is not exist already in your app
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With