Click here to Skip to main content
16,016,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How do i get the values of label on my iframe and pass it to the default page?

What I have tried:

Page load of default page:
C#
protected void Page_Load(object sender, EventArgs e)
{
   if (Session["name"] != null) 
   {
      lblName.Text = Session["name"].ToString(); // I have also tried to do this without the if statement.
   }
}

Page load of 2nd page or my iframe src:
C#
protected void Page_Load(object sender, EventArgs e)
{
   lblName.Text = name.Value;
   Session["name"] = lblName.Text;
}
Posted
Updated 22-Feb-16 8:28am
Comments
ZurdoDev 22-Feb-16 10:20am    
You already asked this before. Where exactly are you stuck? You only set the Session value in the 2nd page so if it loads after Default, default can't get to it. This should be very easy to understand so please try to explain where you are stuck.
Member 11525563 22-Feb-16 11:04am    
I need to get the value of labels of the 2nd page so that on load of the default page the values should be displayed. If session is not possible for this, do you know any other way on how to do this??
ZurdoDev 22-Feb-16 11:12am    
1. As mentioned last week, reply to the comment so that we get notified. Don't add a new comment to your own question.
2. Explain exactly what is happening. Is default the first page loaded or second page?
Member 11525563 22-Feb-16 11:23am    
the default page is the first page loaded.
ZurdoDev 22-Feb-16 11:28am    
Then how can it get values from a page that hasn't loaded yet?

1 solution

As discussed in comments, because of the order of events that you have it sounds like you should use the jquery's document.ready event in the 2nd page and have it reference the label on the default page.

For example:
JavaScript
$(document).ready(function () {
 window.parent.document.getElementById('lblName').Value= document.getElementById("lblName").Value;
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900