Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Asp.net从代码隐藏加载框架src_C#_Asp.net - Fatal编程技术网

C# Asp.net从代码隐藏加载框架src

C# Asp.net从代码隐藏加载框架src,c#,asp.net,C#,Asp.net,在单击按钮时,我无法将“代码隐藏”中的框架src设置为在我的模式中使用。框架src正在获取值,但未在模式中显示页面。 模态码 <div class="modal fade " id="modal-info" role="dialog" data-keyboard="false" style="border: none; height: 500px;" > <div class="modal-dialog col-m

在单击按钮时,我无法将“代码隐藏”中的框架src设置为在我的模式中使用。框架src正在获取值,但未在模式中显示页面。 模态码

         <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">&times;</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>
它仅在页面加载时设置框架src时有效

     protected void Page_Load(object sender, EventArgs e)
    {
        frameinfo.Src = "../Popups/staff_leave_calender.aspx";

    }
我需要做一些类似的事情

         Session["leaveid"] = StrID;
       frameinfo.Src = "../Popups/staff_leave_calender.aspx?lvv=" + StrID;

将在模态中加载的页面中使用Str ID。还有什么其他选项或我可以做什么。

从javascript完整代码中使用它 在您的aspx文件中,在顶部脚本中添加

  <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>

$(文档).ready(函数(){
/*获取iframe src属性值,即YouTube视频url
并将其存储在变量中*/
var url=“../Popups/staff_leave_calendar.aspx?lvv=“+”;
/*在以下情况下为iframe src属性指定空url值:
模式隐藏,停止视频播放*/
document.getElementById(“”)on('hide.bs.modal',function(){
$(“#frm”).attr('src',”);
});
/*将最初存储的url分配回iframe src
再次显示模态时的属性*/
document.getElementById(“”)on('show.bs.modal',function(){
$(“#frm”).attr('src',url);
});
});

在代码隐藏文件中,如果应用程序中不存在会话leveID,则创建会话leveID

该会话只能通过单击按钮获取int StrID=(int)e.Appointment.ID;会话[“leaveid”]=StrID;试试看,我认为它会工作,因为我有相同的代码为你管视频弹出和它的作品很好
  <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>