Dynamically add an iFrame to a page?

I need to create a composite page consisting of other pages in our system.

Is it possible for me to dynamically add iFrames to the page, each with its own src, pointing to different URLs that are defined on the fly? If so, is there a preferred method for this?

Otherwise, I need to reorganize other pages into user controls so that I can add them as needed.

+4
source share
3 answers

Although I would seriously consider revising your pages in usercontrols if you want the "pages" to interact with each other. But for the question itself: you can add LiteralControls to your page (containing iFrames) or to the placeholder.

PlaceHolder1.Controls.Add(new LiteralControl("<iframe src='mypage.aspx'></iframe>")); 
+3
source

You can do this the same way as dynamically adding some kind of .net control to the page, but you need to add the HtmlGenericControl

+3
source

You can use the Document Object Model (DOM) / Javascript [1,2] to add iframes to your page. If you are better off using C #, you will have to cancel the transfer before modifying the document, I think (I'm not an expert in C # / asp).

0
source

Source: https://habr.com/ru/post/1310352/


All Articles