Dynamically load HTML inside the iframe placed in asp.net page.

Post date: Apr 9, 2011 1:23:59 PM

Here i want to dynamically load my HTML inside the panel  iframe in asp.net page

1. I add one panel, and inside the panel i add iframe

  <asp:Panel ID ="PnlHTML" runat ="server"  Height="100%" Width ="100% ">

  <iframe ID="IHTMLFrame" runat="server"></iframe>   

                      

  </asp:Panel>

 2. Then i want to load HTML inside the IHTMLFrame at runtime. So i need to access IHTMLFrame "src" attribute using following code

protected void Page_Load(object sender, EventArgs e)   

{

String choice = "Software"

//Call the HTMLControl and Find the iframe control using that ID

HtmlControl iframe = (HtmlControl)PnlHTML.FindControl("IHTMLFrame");

//based on the request i can change the src and load different parameters

if ( choice== "Software") {

    iframe.Attributes["src"] ="https://sites.google.com/site/greateindiaclub/software-        zones";

 }//if hacking

else if ( choice== "Hacking"){

     iframe.Attributes["src"] ="https://sites.google.com/site/greateindiaclub/hacking";

               }      

}

  

  3. Job is done......