Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change frame on button click

Status
Not open for further replies.

Erics44

Programmer
Oct 7, 2004
133
GB
Hi
I have a question

using the code

<a href="page1.asp" target="top">GoTo Page1</a>

How do I make this on click of a button rather than a hyperlink? can i use

<a href="page1.asp" target="_top"><Button Text="Click Here"></button></a>

?

Thanks for your time
 
.NET 2.0:

<Asp:button onclientclick="top.location.href='page1.asp';"....


.NET 1.0:

<Asp:button onclick="top.location.href='page1.asp'"....


Known is handfull, Unknown is worldfull
 
Hi
Thanks a lot for your reply

I get an error saying that the top is not a member of my form.

I am clicking a button the "side" frame and I want it to appear in the "top" frame.

Thanks again
 
try changing:
top.location.href

to:
parent.frames['top'].location.href


note:
top is a reserved JS keyword, i would advise to use some other name...

Known is handfull, Unknown is worldfull
 
still doesnt like it, says it doesnt recognise "frames"

I have changed the frame name to MainFrame in all places

I am able to do it using

<input type="button" onclick="changePage('PageName.aspx');">

changePage function is

function changePage(mainURL)
{
parent.Frames['MainFrame'].location.href = mainURL;
}

but I cannot manage to get it to work isung the asp:button no matter what I try

Thanks again for your help
 
you are using .NET 2?

do a view source of the page and give me the HTML that is outputted for the button...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top