Last Updated: 2001
Post data is read-only on the server. Thus if we want to change the value of post data on the server before passing it on to another form we cannot.
MSDN describes a complex method of passing properties between forms. That method has a major drawback in that the called form has to have a reference to the calling form in the aspx and a cast to that form in the aspx.cs. If you want to call the same form from two places, it simply isn't possible.
However, if we use an interface, we can:
ObjParams.cs
interface IObjParams {
string GetParam1();
}
MyCallingForm.aspx.cs:
public class
MyCallingForm : System.Web.UI.Page, IObjParams { ....
...
public
string GetParam1() {
return txt1.Value;
}
...
private
void Button1_Click(object
sender, System.EventArgs e) {
txt1.Value="1234";
Server.Transfer("MyCalledForm.aspx",
true);
}
}
MyCalledForm.aspx.cs:
....
if
(!Page.IsPostBack) {
string res=((IObjParams)
Context.Handler).GetParam1();
....