Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 contructing a multi-frame page dynamically

Author  Topic 

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-12-03 : 15:53:36
hi,
have u ever opened multiple pages in the same page. each aspx wil be part of a frame withing the main page
let s say in the code, I want to make a page that includes page1.aspx, page2.aspx and page3.aspx each of these in a frame withing the page.
thanks

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-12-04 : 05:19:45
using frames is agaist current desigh standards.

if you really must than create a html page and have each frame's source set to the proper aspx page.

why are you trying to do this though?
maybe web parts can help you?



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

jhermiz

3564 Posts

Posted - 2006-12-04 : 08:21:01
Definately consider web parts for your project as you can have multiple containers within one page. Start with a container using a div tag. Then create 4 more containers within that div tag. Then you will need to drag and drop a WebPartZone container into each frame. That should get you started. Let me know if you need a sample application.

Jon





Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]

RS Blog -- [url]http://weblogs.sqlteam.com/jhermiz[/url]
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-12-04 : 08:23:10
Are you sure you don't want 3 user controls (ASCX) on the same page, instead of 3 ASPX pages? That's what user controls are for -- you create them and put them on any pages that can use them, sort of like frames but much better because they can all access the master page server side, and the parent page can access any public members of the controls, all using server-side code.

Even if those ASCX pages need to sometimes be on their own page, you can just create container ASPX pages for those controls.



- Jeff
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-12-04 : 11:42:51
Sorry I didn t specify the requirements correctly. Here is what I need:
i ll have a check box list. Each checkbox will be associated to a url address like: the checkbox1 is associated to http://url1 checkbox2 is associated to http://url2 ...and so on. According to the checkboxes the user will check off, i will load a page containing multiple frames. Each frame will include the page related to its URL defined in the checkbox list. I load a page including only the URLs of the checkboxes that the user chose.
Thanks a lot.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-12-04 : 11:53:00
load where?



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-12-04 : 12:03:22
You might want to look into using HTML's IFRAME tag, if you haven't used that before. Basically let's you create in-line frames.

But as mladen said earlier, I would avoid frames in general if you can ... maybe step back and give us a more concrete example of what you are trying to do.

- Jeff
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-12-04 : 13:10:03
load all the selected pages (according to the selected checkboxes) in a brain new multiframwe page.
For example: I will display a page with 3 frames: first frame contains google home page, second frame contains ebay and third page contains yahoo home page. All this because let s say the user checked off yahho, ebay and google in the checkbox list.
Thanks
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-12-04 : 13:18:58
then put 3 frames in your page and then set each frames src with javacsript in the onclick event of the checkbox.



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-12-04 : 14:20:34
yes, but if the user checks off 4 checkboxes, then i will have to load a frameset with four frames according to the checkboxes. so the framset or number of iframes has to be set dynamically according to what the user chooses.
Thanks
Go to Top of Page

jhermiz

3564 Posts

Posted - 2006-12-04 : 14:23:11
If you used web parts you could accomplish this very easily as their is a Web Page Web Part property for a control. They can all be added dynamically as well. Let me make a book recommendation:

Darren Neimke's "ASP.net 2.0 Web Parts in Action"


Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]

RS Blog -- [url]http://weblogs.sqlteam.com/jhermiz[/url]
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-12-04 : 14:59:38
quote:
Originally posted by rtutus

yes, but if the user checks off 4 checkboxes, then i will have to load a frameset with four frames according to the checkboxes. so the framset or number of iframes has to be set dynamically according to what the user chooses.
Thanks



Then use a simple REPEATER control and generate as many IFRAMES as you need. It's the same as generating DIV's or table rows or anything other HTML element on the page based on a datasource, only your template contains IFRAME tags.


- Jeff
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-12-04 : 23:31:39
I put 6 iframes in aspx page. In my Checkboxlist server control Whenever the user checks off a checkbox, In code behind I build a string including the list of all the selected URLs with the format: 'page1','page2',...., Then I pass that string to a javascript function that accepts 6 arguments: arg1, arg2...,arg6 (some arguments will just be empty when i call the function)

In the javascript function, I have this to set the URL for the iframe:

if (arg1!=null) document.getElementById("myframe1").src=arg1;
if (arg1!=null) document.getElementById("myframe1").src=arg1;
....etc

The result:
Here the result I got: If the user selects 2 checkboxes, I get 6 iframes with the first 2 set to the right URLs that the user selected and the last 4 iframes just empty.
I guess we are advancing (thanks for the iframe idea)
Now: if the user selects only 2 checkboxes, How can I get rid of the last 4 empty iframes on the page when the user didn t select them and display only 2 iframes.
The same thing if the user selects only 4 checkboxes. I don t want to have 6 iframes with the 4 first set to the selected URLs and the last 2 mainly empty. I want only 4 iframes displayed on the resulting page.

I guess this a javascript function since, remember I implemented the logic of setting iframes' URLs in javascript code.
Thanks a lot guys.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-12-04 : 23:47:26
It's fairly trivial JavaScript to create as many iframe elements as you need and set their URLs, I'd recommend using DOM methods to create them:

http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/appendchild.asp?frame=true

I can't say I think this is a good layout though. Very easy to get cluttered and chopped off, and don't be surprised if a number of JS-heavy pages don't work properly when they're framed.
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-12-05 : 01:02:53
But can document.createElement() create an iframe like: document.createElement("iframe")
Thanks.
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-12-05 : 01:54:03
YOU RE RIGHT robvolk. i could create an iframe with document.createElement() and add it to document.body.appendchild
I will see what pbs I ll encounter next in my journey . thanks 2 all of u guys for your help.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-12-05 : 08:25:10
I think you would be much better off to do this server-side, as opposed to client-side. Much, much easier and it will work with more browsers.

Also -- do not forget that cross-domain frames are often blocked by security settings on browsers these days ....

- Jeff
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-12-05 : 08:37:14
i must stress again to not use frames.
if you must, use divs with IFRAME in each one.




Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-12-05 : 13:23:12
Ok, how do I do that differently to avoid trouble in future and for the code to be cross browser compatible or on the server side?
P.S: Spirit, I am using iframe and not frame
P.S j.Smith: If I use repeater for server side, what d be the datasource in my case?
Thanks for having walked me through this.
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-12-05 : 14:08:29
I did this on server side but it was slow (at least it worked on both firefox and IE which didn t when I used the client side version):
HtmlGenericControl IfURL = new HtmlGenericControl("iframe");
IfURL.ID = "myNewIframeIdd" + i;
IfURL.Attributes.Add("src", this.myChkBoxList.Items[i].Value);
HtmlTableRow tblRw=new HtmlTableRow();
HtmlTableCell tblCell=new HtmlTableCell();
tblCell.Controls.Add(IfURL);
tblRw.Cells.Add(tblCell);
MyTable.Rows.Add(tblRw);

Thanks.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-12-05 : 14:48:40
DON'T USE HTML TABLES. Use DIVs (like everyone has been suggesting)
Go to Top of Page
    Next Page

- Advertisement -