Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7070949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:37:41+00:00 2026-05-28T05:37:41+00:00

I try to pass some value from one page to another but at the

  • 0

I try to pass some value from one page to another but at the run time I get exception.

Here is my ASP code:

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

Enter a value to post:
<asp:textbox id="TextBox1" 
  runat="Server">
</asp:textbox>

<br /><br />

<asp:button id="Button1" 
  text="Post back to this page"
  runat="Server">
</asp:button>

<br /><br />

<asp:button id="Button2"
  text="Post value to another page" 
  postbackurl="Button.PostBackUrlPage2cs.aspx" 
  runat="Server">
</asp:button>
</asp:Content>

Here’s the code-behind on the destination page:

 void Page_Load(object sender, System.EventArgs e)
    {
        string text;

        // Get the value of TextBox1 from the page that 
        // posted to this page.
        text = ((TextBox)PreviousPage.FindControl("TextBox1")).Text;

        // Check for an empty string.
        if (text != "")
            PostedLabel.Text = "The string posted from the previous page is "
                               + text + ".";
        else
            PostedLabel.Text = "An empty string was posted from the previous page.";
    }

I get this Exception:

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

I took the example from msdn.

Why do I get this exception?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:37:42+00:00Added an answer on May 28, 2026 at 5:37 am

    Assuming you have this inside UpdatePanel, set the button as the post back trigger:

    <Triggers>
        <asp:PostBackTrigger ControlID="Button2" />
    </Triggers>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to pass some variables from one class to another, but the code
I'm trying to pass some values from one .aspx page to an handler (.ashx).
So I pass the ID value from one form to the next using Docmd.OpenForm
I'm trying to pass some parameters (a couple of strings) from a page to
Im trying to pass some values into a text box from a child page
If you try to pass the username/password to OpenVPN from a file via the
I have a get-parameter with name controller . When I try to pass it
I followed tutorial from cocos2d official site . I try to create some items
I am stuck on passing data from one ViewController to another. The scenario is
I have packed some of my code into a function. But when I try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.