简体   繁体   English

刷新页面时刷新iframe

[英]Refresh iframe when refreshing page

i have web page it has a page header content like main menu,logo and so..on.. 我有一个网页,它有一个页面标题内容,如主菜单,徽标等。

and in iframe i am loading the side menu and content. 在iframe中,我正在加载侧边菜单和内容。 while loading the web page i am using an empty home page to display. 加载网页时,我正在使用一个空主页显示。 after some time in mid of some page while refresing the page it reloads the home page. 在翻阅该页面的某个页面中间的某个时间后,它将重新加载主页。 But i need to display the page that i am using as a current page 但是我需要显示我正在用作当前页面的页面

code is 代码是

<form id="form1" runat="server">
<div>
    <table>
        <tr>
            <td style="vertical-align: top; width: 100%" height="115px">
                <div>
                    <uc1:MainMenu ID="ucMainMenu" runat="server" />
                </div>
            </td>
        </tr>
        <tr>                
            <td>
                <iframe src="HomePage.aspx" runat="server" width="1250px" height="675px" id="ifSideMenu"
                    frameborder="0"></iframe>
            </td>
        </tr>
    </table>
</div>
</form>

in that iframe deafult page is Homepage.aspx,it is empty page. 在该iframe默认页面中,Homepage.aspx是空白页面。 When i clicked the sub menu it loads the content like AddMaster.aspx. 当我单击子菜单时,它将加载类似AddMaster.aspx的内容。 When i refresh the page it loads Homepage.aspx, but i need to display AddMaster.aspx 当我刷新页面时,它将加载Homepage.aspx,但是我需要显示AddMaster.aspx

help me 帮我

this code will help u to refresh the iframe only.. not the whole web page. 此代码将帮助您仅刷新iframe,而不刷新整个网页。 but., i dont understand your que clearly brother. 但是,我不太明白你的兄弟。

<IFRAME id="frame1" src="http://www.google.com/"  runat="server">

    <script type="text/javascript">
    function refreshiframe()
    {
        parent.frame1.location.href="http://www.google.com/"
        setTimeout("refreshiframe()",3000);
    }
    </script>

<body  onload="refreshiframe();">

I finally found the answer for this question. 我终于找到了这个问题的答案。

It may help for others. 它可能对其他人有帮助。

Add the below code in HomePage.aspx and other pages that are going to load in the iframe 在HomePage.aspx和其他要在iframe中加载的页面中添加以下代码

Session["CurrentPage"] = Request.RawUrl.ToString().Replace(Request.ApplicationPath.ToString() + @"/", ""); 

in Main Page in page load event. 在页面加载事件的主页中。

if (Session["CurrentPage"] == null)
    Session["CurrentPage"] = "Exit_Tracker.aspx";

ifSideMenu.Attributes["src"] = Session["CurrentPage"].ToString();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM