Reputation: 258
I have multiple iframe in my asp.net page. But all this iframe are loading through loop and having same page in all. These all iframes are loading at last, after loop completes and because of these i am getting last loop data in all iframes.
What to do for this.
This is my main page code where Iframe created in loop:
for (int iCount = 0; iCount < rcChartSubject.Items.Count; iCount++)
{
SetChart();
if (iCount.Equals(1))
{
divRadarChart1.InnerHtml = "";
divRadarChart1.InnerHtml = "<iframe class='RadarSize' src='RadarChart.aspx' frameborder='0' width='680px' height='480px'></iframe>";
divRadar1.Visible = true;
}
else if (iCount.Equals(2))
{
divRadarChart2.InnerHtml = "";
divRadarChart2.InnerHtml = "<iframe class='RadarSize' src='RadarChart.aspx' frameborder='0' width='680px' height='480px'></iframe>";
divRadar2.Visible = true;
}
}
In SetChart() method i am setting global variable for generating chart. But if for loop is for 4 times then iframe page is loading at last 4 times instead of loading in for loop one by one and due to this i am getting last for loop global variables.
And On RadarChart.aspx page I am using those global variables value like below :
protected void Page_Load(object sender, EventArgs e)
{
ltRadar.Text += string.Format("<input type='hidden' name='chxl' value='0:|{0}|1:|{1} |' />", strRadarChartSubjectLabel, strRadarChartAxisValue);
}
Upvotes: 1
Views: 1972
Reputation: 6543
All Iframe will loads pages at last when your loop completes its execution. So at that time you will have last data in all your variables if you are using global variables and set those variable's value in your iframe page. Better you try with query string where you can pass your all variable's values and set those values in page. So all pages will have seperate data to load.
Try this :
<iframe class='RadarSize' src='RadarChart.aspx?q1=val1&q2=val2' frameborder='0' width='680px' height='480px'></iframe>
Upvotes: 3