Click here to Skip to main content
15,917,652 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,I want to create a iframe dynamically in codebehide page ,how can i do so,
which class should i use.
Posted

 
Share this answer
 
Try Literal Control to embed an iFrame:
C#
LiteralControl litCon = new LiteralControl();
litCon.Text = "<iframe name='testiFrame' id='runtimeIFrame'  frameborder='no' scrolling='auto' height='400px' width='100%'  src='http://www.google.com' style='left:0; background-color: beige;'></iframe>";
myPanel.Controls.Add(litCon);

Refer: MSDN: LiteralControl Class[^]
 
Share this answer
 
Comments
software_Engi08 13-Jul-12 19:22pm    
but i want to set src dynamically ???
Sandeep Mewara 14-Jul-12 1:32am    
:doh:
Did you read what I shared? It's a code behind lines. Text is a string and you can very well set it at runtime.
Ex:
litCon.Text = "<iframe name='testiFrame' id='runtimeIFrame' frameborder='no' scrolling='auto' height='400px' width='100%' src='" + ISETSOURCEOFIFAMEHERE +"' style='left:0; background-color: beige;'></iframe>";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900