Context.Handler ?

  • Thread starter Thread starter Daniel Groh
  • Start date Start date
D

Daniel Groh

I'm studying for C# Cert and i found a question about Context.Handler and i
didn't understand.
Could someone please explain me when and how do i use ?
I'd like to make webapplication here for understanding better! wich kind of
webapplication could i do ?

Thanks in advance,

--
Daniel Groh
CTF Technologies do Brasil LTDA
Analista Programador
Fone: 11 3837-4203
E-mail: (e-mail address removed)
 
Context handler is one the many ways of exchanging data between aspx pages.
See the example below. It work with Server.Transfer only.

public class Context1 : System.Web.UI.Page
{
// Create a property to return the value of a text box.
internal string Value
{
get
{
return txtValue.Text;
}
}

private void butNext_Click(object sender, System.EventArgs e)
{
// Transfer to the next page.
Server.Transfer("Context2.aspx");
}
}


public class Context2 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
// Declare an object using the previous page's type.
Context1 LastPage;
// Coerce the Context.Handler object to the page's type.
LastPage = (Context1)Context.Handler;
// Display the Value property.
lblValue.Text = LastPage.Value;
}
}

private void butBack_Click(object sender, System.EventArgs e)
{
// Transfer back to the preceding page.
Server.Transfer("Context1.aspx");
}
}


JB
 
Back
Top