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 8615957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:30:22+00:00 2026-06-12T05:30:22+00:00

Can anyone give me a working example of PostbackUrl where both the target page

  • 0

Can anyone give me a working example of PostbackUrl where both the target page and previous page have masterpage.

For example, let assume I have two pages default1.axpx and default2.aspx. Both of them have a masterpage MyMasterpage.masterpage

I want to postback from default1.aspx to default2.aspx and then extract data from default1 page controls in default2 page.

How can I do that?

  • 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-06-12T05:30:23+00:00Added an answer on June 12, 2026 at 5:30 am

    You should have titled this question “How do I find a control in a ContentPlaceholder?”, because your problem is not that PreviousPage doesn’t work, it’s that you don’t understand how ContentPlaceholders work.

    This problem has nothing to do with a master page per se, and is entirely related to using a ContentPlaceholder, which is a Naming Container in asp.net parlance. FindControls does not search inside Naming Containers, which is exactly how they are designed.

    PreviousPage works fine with master pages, thus my confusion about what they have to do with your problem. You can access any property on the previous page that you want, and it will in fact work. For example:

     HtmlForm form = PreviousPage.Form; // this works fine
     Control ctrl = PreviousPage.Master.FindControl("TextBox1"); // this works as well
    

    The problem you are likely encountering is that you’re trying to use FindControl() to find a specific control in the content page, and it’s not working, precisely because you’re calling FindControl on the PreviousPage, and not on the naming container that the control you’re looking for exists in.

    To find the control you want, you just have to do a FindControl on the naming container. The following code works fine, assuming the placeholder is named ContentPlaceHolder1.

    var ph = PreviousPage.Controls[0].FindControl("ContentPlaceHolder1");
    var ctl = ph.FindControl("TextBox1");
    

    You can verify that this problem has nothing to do with PreviousPage by using the following code, which uses only a single page and looks for the control on itself. Place a textbox on your Default.aspx page called TextBox1. Then, in the Page_Load function of the code behind of Default.aspx.cs put this code, then run it in the debugger and step through it.

    protected void Page_Load(object sender, EventArgs e)
    {
        // Following code should find the control, right?  Wrong. It's null
        var ctrl = Page.FindControl("TextBox1"); 
    
        // assuming your content placeholder in the masterpage is called MainContent, this works.
        var ctrl = Page.Controls[0].FindControl("MainContent").FindControl("TextBox1");
    }
    

    So please, don’t go saying things like “the PreviousPage doesn’t work as it should if the pages have masterpage”, because it’s working EXACTLY as it should. The problem is that you don’t know how it should be working. Learn how the page object model works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone give me the working example of reading two files simultaneously through threads?
Can anyone give me an example of these attributes in action: stroke-dasharray, stroke-linecap, stroke-linejoin
Can anyone give me any pointers. I have a text file that contains dates
Can anyone give me an example of how I can consume the following web
Can anyone give me the 411 on shopping carts? I have a client that
Can anyone give me a basic example of how to clear specific form inputs
Can anyone please give an example how to use the OnExited event in C++,
Could anyone please give me a short working example of a C# class which
Can anyone give tell me how to search for a particular word in a
Can anyone give me a cross-browser supported solution for this problem?

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.