views:

34

answers:

2

Hi All,

I am using two frames in my page. The page in Main fame will get the input and Top frame has to display the result page.

I am using the following code in the mainframe page. But it shows

error:"Microsoft JScript runtime error: 'topFrame' is undefined"

Code:

  <frame src="" id="topFrame" target="topFrame"  scrolling="no">
  <frame src="txtPage.aspx" target="topFrame" name="mainFrame">

  txtPage(MainFrame)
  Response.Write("<script>topFrame.location.href=\"Homepage.aspx\";</script>");
A: 

Try window.topFrame.location.href or parent.topFrame.location.href.

Paperjam
I am getting the following for both options. "Microsoft JScript runtime error: 'window.topFrame.location' is null or not an object"
Geetha
+1  A: 

ok, for starters (and no offence here), but frames suck. Could you try using iFrames?

If you use an iFrame, then you can have a tag like

<iframe src="" id="topFrame" target="topFrame"  scrolling="no" runat="server"></iframe>

then you can set the iFrame attribute

topFrame.Attributes.Add("src", "/homepage.aspx")
rockinthesixstring
note: I used a .NET example because I "assumed" you were using .NET... sorry if I'm wrong.
rockinthesixstring
I would try the same approach but with a `<frame>`. Basically anything that you `runat="server"` in your code will allow you to manipulate it from the code behind. In this case `Attributes.Add`
rockinthesixstring
Can you store the `topFrame` variable in some kind of Global variable or Session variable? Then you can call on that variable from the page that you put the code in. `topFrame.Attributes.Add("src", Session("topFrame")`
rockinthesixstring
where `Session("topFrame") = "/homepage.aspx"`
rockinthesixstring
Hi, one more doubt. i am following you the problem is, topFrame.Attributes.Add("src", Session["topframe"].ToString()); in page load but this event ti not firing.
Geetha
Can you edit your question to show us where you are so far. I'd like to see the markup and the code behind for the pages that are in question.
rockinthesixstring