ASP PreviousPage.FindControl

Posted on 2007-07-26
Last Modified: 2008-01-09
I have a Text Box that I Type Information in and then I Click a button and i want to get the information from the Text box on the current page i am trying to use PreviousPage.Findcontrol and it keeps saying the NullException
Question by:DRSLT
    LVL 14

    Accepted Solution

    as far as I know, previous page is only applicable in cross page postback situations, or it says will also work with Server.Transfer, but haven't seen examples using the latter.

    are you using server.transfer, or using the button PostBackUrl property to send it to the next page?
    LVL 14

    Expert Comment

    also, a good idea, if there is any other way to get to that page, to explicitly check that PreviousPage is not null before doing anything with it, just good practice to make sure an object, actually is something, before doing something with it.
    LVL 5

    Assisted Solution

    Is your textbox part of a <form> ?
    If yes, the button you click could be the "submit" button of that form
    and then you could simply use the Request.Form object to find the content of that textbox ...

    wouldn't it be simpler ?
    LVL 1

    Author Comment

    I ended up using Server.Transfer(~/PageName.aspx) and on the Next Page i used ((TextBox)this.PreviousPage("id")).Text and it gets the value and i am going to check to make sure the previous page is defined if not i will bounce them back to the original page.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now