Wednesday, December 25, 2013

Using Htmlframe tag instead of Iframe tag

I recently was working on a project where I had to use an Iframe. This Iframe would get querystring parameters and pass it to the associated page in the Iframe. Now, if your using a standard .aspx page, you won't need this tip. This tip if for people that are using Iframes in their controls. Since controls use System.Web.UI.UserControl and not the standard System.Web.UI.Page that pages use. You won't be able to use the standard Iframe tag. Instead you'll need to use the server Iframe version. Before using this server tag, you'll need to add the snippet below to your web.config in the controls section. Then add the following snippet in your control. Hope this was helpful!  
 <controls>
      <add assembly="System.Web" namespace="System.Web.UI.HtmlControls"
tagprefix="asp"/>   </controls>

 <asp:HtmlIframe frameborder="0" height="650" id="myiframe" name="myiframe" runat="server" src="prefcontent.aspx" width="400">
</asp:HtmlIframe>