将会话变量从页面传递到页面 [英] Passing session variable from page to page

查看:61
本文介绍了将会话变量从页面传递到页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取iframe上的标签值并将其传递到默认页面?



我尝试过的内容:



默认页面的页面加载:

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:

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.
   }
}



第二页或我的iframe src的页面加载:


Page load of 2nd page or my iframe src:

protected void Page_Load(object sender, EventArgs e)
{
   lblName.Text = name.Value;
   Session["name"] = lblName.Text;
}

推荐答案

正如评论中所讨论的那样,由于您拥有的事件顺序,听起来应该使用jquery的document.ready事件在第二页中,并在默认页面上引用标签。



例如:

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:


document )。ready( function (){
window .parent。 document .getElementById(' lblName')。Value = document .getElementById( lblName)。值;
});
(document).ready(function () { window.parent.document.getElementById('lblName').Value= document.getElementById("lblName").Value; });


这篇关于将会话变量从页面传递到页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆