We know that ASP.NET can be implemented with session when passing objects between different pages. Now I want to introduce another method to achieve the purpose.
Main ideas: We need two pages, a Sender.aspx is responsible for sending the object you want, and a Receiver.aspx is responsible for accepting the SEND. Sender.aspx mainly uses Server.Transfer to terminate the execution of the current page and start to transfer to Receiver.aspx to remove the object.
Implementation:
Itransfer.cs namespace sunrise.sample.formtransfer {///
Myclass.csnamespace sunrise.sample.formtransfer {///
Public myclass () {}
Public string message {get {return;} set {this._strime = value;}}
}
Backstage code file receiver.aspx.cs
Namespace Sunrise.Sample.FormTransfer {///
if (! ispostback) {// Judging the httphandler of the current page, if the ITRANSFER interface is implemented into iTransfer if (CONTEXT.HANDAL ITRANSFER) {MySender = (Itransfer) Context.handler;
Response.write (MySender.MyObject.Message);} else {response.redirect ("sender.aspx");}}}.
Backstage code file sender.aspx.cs
Namespace Sunrise.Sample.FormTransfer {///
Private void Page_load (Object Sender, System.EventArgs E) {_objmyObject = new myclass ();
// Implement ITRANSFER interface public myclass myobject {get {return this._objmyObject;} set {this._objmyObject = value;}} ///
// Call server.transfer (), turn to execute Receiver.aspx Server.Transfer ("receiver.aspx");}..
After compiling, execute sender.aspx, click the BTNSend button, you can see the execution result: the Receiver.aspx page got the MyObject object, and showing the value of myObject.Message on the page; Test ";
Project requires complete source code please contact the author: szumic@hotmail.com http://sunrise.szu.edu.cn