Jump to content
  • Advertisement
Sign in to follow this  
jen6677

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

This topic is 4941 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Honestly if you have control over it you shouldn't be using frames at all, as in the majority of cases they make for badly formed ASP.NET applications.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!