Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8039183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:29:23+00:00 2026-06-05T03:29:23+00:00

I have an iframe that has a dynamic URL based on the results of

  • 0

I have an iframe that has a dynamic URL based on the results of web API call. What is the best way of setting its src in the aspx page? Here is an example of the iframe:

<iframe id="dynamicframe" runat="server"></iframe>

Should I set it directly in the codebehind like so:

dynamicframe.Attributes["src"] = "http://dynamicurl.com";

Or should I create a property in the codebehind and reference it in the iframe:

<iframe id="dynamicframe" src="<%= dynamicFrameUrl %>"></iframe>

Or some other method altogether?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:29:24+00:00Added an answer on June 5, 2026 at 3:29 am

    This is a general question that can stands the same for any html tag.

    The alternative third option is to use a literal control and fully render the iframe on code behind as:

     txtLiteral.Text = "string.Format(
          "<iframe id=\"dynamicfrmae\" src=\"{0}\"></iframe>",   PageUrlForSrc  );
    

    The different for all methods :

    Direct write on page <%= %>

    1. Not work with update panel
    2. Its run the moment the page send to the browser (and not before on the page steps)
    3. Not accessible as control

    This is the method that I avoid most. I use it only when I like to left some calculations for later and avoid page cycle, or when I have responce.flush() just before it.

    Write it using to literal

    1. Compatible with UpdatePanel
    2. Not accessible as control

    Write it as attribute on code behind

    1. Make the control pass the steps of the html cycle
    2. Is accessible else where on the page as variable
    3. The id of this control may change but you can avoid conflicts

    All methods have their purpose, and I used then according what they fit best.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sidebar(iframe) that has its own instance on each tab you open.
I have a web page that has a DIV and an IFRAME. When a
I have an iframe that has dynamic content. If the answers specific questions, additional
I have a page that is loading an iFrame that has it's source based
I have an iframe-based online help system that has worked well for years. With
I have a web application with an iframe that needs to communicate with its
I have this wonderful iFrame that has wonkey dimensions that I want to change
I have a page which has an Iframe. In that Iframe, there are six
I have a page that contains an iFrame point to a URL with parameters.
I have a page that is already in an iframe that has another page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.