简体   繁体   中英

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. 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. When i clicked the sub menu it loads the content like AddMaster.aspx. When i refresh the page it loads Homepage.aspx, but i need to display AddMaster.aspx

help me

this code will help u to refresh the iframe only.. not the whole web page. 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

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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