How to use a frame on an ASP.NET page?

How do you fix the use of a frame on an asp.net page, so I have a left frame and a right frame, when I click the links on the page presented in the left frame, it loads the corresponding page into the right frame? In addition, I need to have a main page on all pages of the right frame.

How can I do it? or is there any other way to achieve the same effect?

Thanks Ray.

+6
iframe
source share
4 answers

Yeah. The framework is evil. You should not use them.

They cause problems, but in (very) few edge cases they can be useful and cheaper in terms of development time, they still appear in the generated api documentation quite a lot.

But anyway, when you see how you asked how to use them, here we go

First of all, it depends on whether you want to use a set of frames or just place some iframes on a page, iframes may be simpler, but it will describe a set of frames. Below are some links. If you are digging a return car on archive.org, you will see some examples, as well as Sun online java docs, which used to be in frame sets, but have not looked at them for many years.

http://www.w3schools.com/tags/tag_frameset.asp
http://www.w3schools.com/tags/tag_iframe.asp

Basically, the contents of each frame are separate pages, and the frames themselves should be named in a file that contains a set of frames, which might look something like this:

<html> <frameset cols="25%,75%"> <frame name="_left" src="nav.aspx" /> <frame name="_right" src="foo.aspx" /> </frameset> </html> 

So, for the sake of exercise, give the attribute of the left frame name = "__ left" and name = "__ right" on the right.

Important bits about links
Any links inside your right frame that need to target this frame must have target = "_self", and anyone who needs to leave the frame and set the location of the parent page must have target = "_ top".

Links in your left frame should have the target = "_ right" attribute, and it should load the corresponding document in the right frame when you click the link.

Otherwise, this is normal, treat the contents of the right frame as a regular page, make the main page as usual, all normal html, head, body tags, etc. There is nothing different in frames in aspnet or php or anything else; its just html.

There you have, maybe a few things that I missed, because these days they are not very often used, but sometimes, when accessibility and everything that does not matter, they can be quick and dirty fix. for example, some obscure admin page on a service website that will be visited 12 times a year by a geek who understands what is happening.

So, they are evil, but this should not stop you from learning about them, you will understand why they are evil, and form your own opinion about when and when not to use them.

+5
source share

Frames are generally disapproved of in modern web development for several reasons (I will not go into them here). You better use CSS to create a two-column layout. There are many good lessons on how to make layouts like this all over the web. One example can be found here:

http://www.456bereastreet.com/lab/developing_with_web_standards/csslayout/2-col/

An example on this site is as follows:

http://www.456bereastreet.com/lab/developing_with_web_standards/csslayout/2-col/finished.html

If you want the layout to #main on the screen, just define the height for #main . You just need to add this to your CSS after you are done:

 #main{height:600px} 

Change "600px" to whatever height you need if it doesn't suit you.

To use it on the main page, just have your main page execute the above example and then make the inside of the #main <div /> your main ContentPlaceholder

+3
source share

A short and sweet answer?

Frames and frames are no longer needed or useful in web development, and they create far more problems than they solve.

More details:

There are three things you probably use with frames:

1) . You want to have a navigation bar on the left and have a separate content area on the right, mostly vertical separation.

Non-frame solution:

Use plain HTML and CSS to create 2-column layouts. See Some Other Resources or The Last CSS Layout Guide You'll Ever Need .

2) . You want to have one file with navigation, in which you do not need to have a version on several different pages.

Non-frame solution:

Keep the navigation in a separate file and simply include it in all of your content pages. In ASP.NET, you can create a UserControl or .ascx file and include it in all your changes. Put your navigation in UserControl and you need to change it in only one place.

3) You need faster performance only for the content frame that you want to reload, and not for the navigation frame.

Non-frame solution:

The extra time to load the entire page is negligible, and the simplicity of servicing a single document at the same time due to a slight decrease in performance.

0
source share

you can put iframe code in the body section. example below. try it:)

 <iframe width="100%" height="600px" scrolling="no" seamless="yes" src="https://facebook.com"></iframe> 
0
source share

All Articles