I Have three form Home.aspx and Login.aspx Details.aspx

on home.aspx i have two iframe

in iframe one i open login.aspx

in Login.aspx i have a button btnChangePage


now i want to assign src property of second iframe dynamically
( src="details.aspx" ) on btnChangePage_Click

Please if u have any suggetions please help me

Thanks a lot in advance

I suggest that you use web user controls with .ascx extension instead of iframes. I can tell you how to do what you want with iframes too but it there will be unnecessary details. You can dynamically load the web user controls to different sections of web forms easily.

Please try this code :

IFrame.Attributes("src") = "Folder\details.aspx"

Thanks.

Hello serkansendur,
first thanks for response

please tell me how can use web user controls with .ascx extension instead of iframes.

Hello Kusno,
thanks for response
but above by above code i can't access iframe control on other form code behind
i mean on login.aspx.cs i want to access iframe which is on home.aspx

Hello serkansendur,
first thanks for response

please tell me how can use web user controls with .ascx extension instead of iframes.

Right click to your project choose add new item, select web user control, put what you put in your iframes. then drag and drop the web user control on to your web page(where you would put your iframe). if you want to add the web user control dynamically, add an asp panel control to your page then onload event of your panel control type this : myPanel.Controls.Add(LoadControl("WebUserControl.ascx")); .

Page:

<form id="Form1" method="post" runat="server">
<iframe id="ifrm" runat="server"></iframe>
</form>

Codebehind:

using System.Web.UI.HtmlControls;

public partial class test : System.Web.UI.Page
{
  
    protected void Page_Load(object sender, EventArgs e)
    {
       
       ((HtmlControl)(form1.FindControl("ifrm"))).Attributes["src"] = "http://www.yahoo.com";
    }

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

This article has been dead for over six months. Start a new discussion instead.