找传奇、传世资源到传世资源站!

asp.net webform页面传值的8种方法

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace PassingData{ public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void QueryStringButton_Click(object sender, EventArgs e) { Response.Redirect("QueryStringPage.aspx?Data=" Server.UrlEncode(DataToSendTextBox.Text)); } protected void SessionStateButton_Click(object sender, EventArgs e) { Session["Data"] = DataToSendTextBox.Text; Response.Redirect("SessionStatePage.aspx"); } public string DataToSend { get { return DataToSendTextBox.Text; } } protected void PublicPropertiesButton_Click(object sender, EventArgs e) { Server.Transfer("PublicPropertiesPage.aspx"); } protected void ControlInfoButton_Click(object sender, EventArgs e) { Server.Transfer("ControlInfoPage.aspx"); } protected void HttpContextButton_Click(object sender, EventArgs e) { HttpContext.Current.Items["data"] = DataToSendTextBox.Text; Server.Transfer("HttpContextItemsPage.aspx"); } protected void CookiesButton_Click(object sender, EventArgs e) { HttpCookie cook = new HttpCookie("data"); cook.Expires = DateTime.Now.AddDays(1); cook.Value = DataToSendTextBox.Text; Response.Cookies.Add(cook); Response.Redirect("HttpCookiePage.aspx"); } protected void CacheButton_Click(object sender, EventArgs e) { Cache["data"] = DataToSendTextBox.Text; Server.Transfer("CachePage.aspx"); } protected void HttpPostButton_Click(object sender, EventArgs e) { } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复