Setting the src of IFRAME.

Posted on 2005-04-06
Last Modified: 2010-04-16

I have a WebForm with an IFRAME. I need to be able to set the src of the IFRAME dynamically. Since there is no standard IFRAME control in I tried to set the src of the IFRAME by calling a procedure in the code behind page:

html part:

<iframe id="ifCarFrame" name="ifCarFrame" src="<%# getCarFormAddress()%>">
code behind part:

public string getCarFormAddress()
     //Builds the address for the ChatterBox
     string carFormAddress;

     carFormAddress = "carform.aspx";
     return carFormAddress;

The problem is that it is sending a blank to the WebForm.

Does anyone know how to send a string to the src in an IFRAME html-control?

Thanks for your help,
Question by:tnook
    LVL 17

    Accepted Solution

    <iframe id="ifCarFrame" name="ifCarFrame" src="" runat="server">

    Add the following to the members list in the code behind:

              protected HtmlGenericControl ifCarFrame;

    You can set the src from code as follows:

              private void Page_Load(object sender, System.EventArgs e)
                   ifCarFrame.Attributes["src"] = "newpage.aspx";
                   // Put user code to initialize the page here

    Author Comment

    Genius!!! Thanks!!!


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now