title: How do I dynamically set source of an IFrame?
body: <p>I have an IFrame embedding a youtube video. I want to create a textbox where user (admins) can paste a new src (URL) of video and the IFrame take the new source. Here is what I have so far:</p>
  
  <pre><code>protected void Edited_Click(object sender, EventArgs e)
      {
         // HtmlControl frame1 = (HtmlControl)this.FindControl("frame1");
          string url = TextBox1.Text;
          frame1.Attributes["src"] = url;
  
      }
  </code></pre>
  
  <p>And in the html code is the Iframe:</p>
  
  <pre><code>&lt;div id="video"&gt;
      &lt;iframe title="YouTube video player" runat="server" width="420" 
              frameborder="1" style="height: 265px; float: left; 
              text-align: center;" id="frame1" 
          name="frame1" align="middle"&gt;&lt;/iframe&gt;
         &lt;br /&gt;
         &lt;/div&gt;
  </code></pre>
  
  <p>I don't set any src in the beginning but when I paste a URL in the textbox and hit the button, the Iframe doesn't displays anything.</p>