如何将第2页的值传递给默认页面? [英] How can i pass the value of 2nd page to the default page?

查看:62
本文介绍了如何将第2页的值传递给默认页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的MSG.aspx.cs上的label值传递给Default.aspx.cs。



我在这里使用会话,是吗有谁知道如何做到这一点?



(如果我的问题不明确,程序首先加载Default.aspx.cs然后在Page_Load上它应该调用MSG.aspx.cs然后获取MSG.aspx.cs上的标签值。



我尝试过:



Default.aspx.cs

I want to pass the value of label on my MSG.aspx.cs to Default.aspx.cs.

I'm using a session here, does anyone know any other options on how to do this??

(If my question is not clear, The program is loading the Default.aspx.cs first then on Page_Load it should call the MSG.aspx.cs then get the value of label on MSG.aspx.cs)

What I have tried:

Default.aspx.cs

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



MSG.aspx.cs


MSG.aspx.cs

Match sndrNameMatch = Regex.Match(body, @"From: ([A-Za-z0-9\-]+)", RegexOptions.IgnoreCase);
            
lblName.Text = sndrNameMatch.Value;
Session["name"] = lblName.Text;

推荐答案

您可以从服务器端使用Session,QueryString或Application Cache。从客户端,您可以使用cookie或localStorage。



然而,使用会话没有任何问题所以我建议不要管它。
You can use Session, QueryString, or Application Cache from server side. From the client side you can use cookies or localStorage.

However, there is nothing wrong with using the session so I'd suggest just leaving it alone.


这篇关于如何将第2页的值传递给默认页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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