TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
abc xyz
NA
1
0
passing value between pages
Feb 15 2005 7:01 PM
Hi Am trying to pass data back and forth between 2 web forms in asp.net I tried the Get property but facing issues when trying to return control from Page 2 to Page 1. Am not sure what is going wrong. The scenario that I would like to create is Page 1 click button --> pass values --> Page 2 (capture passed value) Page 2 click button --> pass values --> Page 1 (capture passed value) Attached below is the code snippet that I am using : WebForm1.aspx ( PAGE 1) ----------------------- public string Property1 { get { return TextBox1.Text; } } private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (!IsPostBack) { } else { WebForm2 wf2 = (WebForm2) Context.Handler; Label1.Text = wf2.Property2; } } private void Button1_Click(object sender, System.EventArgs e) { Server.Transfer("Webform2.aspx"); } WebForm2.aspx ( PAGE 2) ----------------------- public string Property2 { get { return Label1.Text; } } private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (!IsPostBack) { WebForm1 sourcepage = (WebForm1) Context.Handler; Label1.Text = sourcepage.Property1; } } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } ///
/// Required method for Designer support - do not modify /// the contents of this method with the code editor. ///
private void InitializeComponent() { this.Button1.Click += new System.EventHandler(this.Button1_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void Button1_Click(object sender, System.EventArgs e) { Server.Transfer("Webform1.aspx",true); } The above code worked fine when I navigate from Page 1 to Page 2, but when it tries to navigate back to page1 - it fails ! Can you pls help ? Thanks
Reply
Answers (
1
)
MSXML serverXMLHTTP
Can I write a var from the ASP and have access to him later?