How we provide the source dynamically for Iframe tag

Posted by Kondapallisrinivas under ASP.NET on 10/17/2012 | Points: 10 | Views : 1989 | Status : [Member] | Replies : 1
Hello All

I am using the code as shown below

<frameset cols="25%,75%">
<iframe name="frame1" src="">
<iframe name="frame2" src="">

If i use it is okay but now i am tring to get the src(source) from .aspx.cs page

protected void Page_Load(object sender, EventArgs e)
int p1 = DateTime.Now.Year;
int p2 = DateTime.Now.Month;
int p3 = DateTime.Now.Day;

URL= "http://hqbusa0369/data/import/NBE/PROD/from_EDI/arc/" + p1 + p2 + p3 ;

I want to use that URL as source for frame1.....

Please help for how i have to use that...

Thank you in advance

Kondapalli Srinivas


Posted by: Ranjeet_8 on: 10/18/2012 [Member] [MVP] Gold | Points: 25

Try this.
Write this code on ASPX

<div runat="server" id="Iframe">

Write this code on ASPX.CS

using System.Text; // Import namespace

StringBuilder sb = new StringBuilder();
sb.Append("<frameset cols='25%,75%'> ");
sb.Append("<iframe name='frame1' src='" + URL + "'> "); // Set your Custom URL
sb.Append("<iframe name='frame2' src=''> ");
sb.Append("</frameset> ");
Iframe.InnerHtml = sb.ToString();

Kondapallisrinivas, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response