Sign in to follow this  
jen6677

[.net] Q regarding frames, target="top" and asp.net buttons

Recommended Posts

Lets say a webpage has 2 frames, top and bottom. Ofcourse, If you click on a link in the "top" frame, the destination page will be displayed in the "top" frame If you want to break out of the frame set and have a frameless page when clicking a link you have to insert the attribute target="_top" to the hyperlink code. ok so far so good, but how do I replicate target="_top" with and asp.net button? That is I want to click on the button and I want the destination to be displayed in a frameless page. Also, is there a way to make a webpage so that it could never be displayed in a frame? Almost like the page would behave as if every incoming link had the attribute target="_top" in it? Thanks.

Share this post


Link to post
Share on other sites
For the first, you need to do it in your code-behind. Best to respond to the PreRender event and call:

myButton.Attributes.Add("target", "_top");

For the second, there's not really a whole lot you can do. You could make your page just redirect to another, opening the redirect in _top (though I'm not sure if that's even possible).

Share this post


Link to post
Share on other sites
Actually now I see what's happening. Unfortunatly you can't do it with the Button class. You'll need to either use the HyperLink class (You can set it's Text property to a <img ...> tag if you like, plus it has it's own Target property). Or, you'll have to write some client-side java script to do it via a Button (or ImageButton).

See this blog for details.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this