问题描述
有用于状态管理的Context.Handler对象...用于将数据从一个页面传输到第二个页面我有问题我只需要三个表单一个第一页(_default)有一个文本框和一个按钮我有完成数据从_default转移到default2页面,我只是想从default2移动到default3而不使用可能有效的context.hadler但问题就在这里,当我从default3返回到default2,在context.handler对象中显示异常时如何我可以处理这个
there is Context.Handler object for state management...which is used to transferring data from one page to second page i have problem i just take three form one first page(_default) there is one textbox and one button i has done data transferring from _default to default2 page and i just want to move from default2 to default3 without using context.hadler that can be posible but problem is here when ever im returning from default3 to default2 that show exception in context.handler object so how i can handle this
推荐答案
private void Button1_Click(object sender, System.EventArgs e)
{
// Value sent using HttpResponse
Response.Redirect("WebForm5.aspx?Name="+txtName.Text);
}
if (Request.QueryString["Name"]!= null)
Label3.Text = Request.QueryString["Name"];
HttpCookie cName = new HttpCookie(Name);
cName.Value = txtName.Text;
Response.Cookies.Add(cName);
Response.Redirect(WebForm5.aspx);
HttpCookie cName = new HttpCookie("Name");
cName.Value = txtName.Text;
Response.Cookies.Add(cName);
Response.Redirect("WebForm5.aspx");
if (Request.Cookies["Name"] != null )
Label3.Text = Request.Cookies["Name"].Value;
// Session Created
Session["Name"] = txtName.Text;
Response.Redirect("WebForm5.aspx");
// The code below shows how to get the session value.
// This code must be placed in other page.
if(Session["Name"] != null)
Label3.Text = Session["Name"].ToString();
// This sets the value of the Application Variable
Application["Name"] = txtName.Text;
Response.Redirect("WebForm5.aspx");
// This is how we retrieve the value of the Application Variable
if( Application["Name"] != null )
Label3.Text = Application["Name"].ToString();
public string GetName
{
get { return txtName.Text; }
}
Server.Transfer(WebForm5.aspx);
Server.Transfer("WebForm5.aspx");
WebForm4 w;
// Gets the Page.Context which is Associated with this page
w = (WebForm4)Context.Handler;
// Assign the Label control with the property "GetName" which returns string
Label3.Text = w.GetName;
这篇关于asp.net使用contaxt.handler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!