Click here to Skip to main content
11,647,748 members (70,056 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0
There is a textbox (id="TextBox1") in Default.aspx page. I want to get the value of the textbox1 from Default2.aspx page protected void Button1_Click(object sender, EventArgs e) { TextBox tb = (TextBox)PreviousPage.FindControl("TextBox1"); if (tb != null) { Label1.Text = tb.Text; } } When I click the button it arises an error : Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 30: //page_load(); Line 31: //Label1.Text = PreviousPage.Name; Line 32: TextBox tb = (TextBox)PreviousPage.FindControl("TextBox1"); if (tb != null) Line 33: { Line 34: Label1.Text = tb.Text;
Posted 28-Apr-13 20:08pm
Edited 29-Apr-13 1:51am
Mohi Uddin Sumon at 29-Apr-13 2:31am
Can't I get a proper answer??

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hi. Firstly I suggest you to add a tag ASP .NET. Secondly if you want to exchange data between pages you should consider to fill GET or POST insformation with your request or/and to add session. The following links might be helpful[^][^][^][^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 500
1 F-ES Sitecore 410
2 OriginalGriff 322
3 DamithSL 315
4 CPallini 250
0 OriginalGriff 1,342
1 994
2 DamithSL 971
3 Sergey Alexandrovich Kryukov 873
4 CPallini 795

Advertise | Privacy | Mobile
Web02 | 2.8.150804.3 | Last Updated 29 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100