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

  • Home
  • SEARCH
  • 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 8392969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:39:39+00:00 2026-06-09T19:39:39+00:00

My web site uses a master page, where I’ve placed two controls, a TextBox

  • 0

My web site uses a master page, where I’ve placed two controls, a TextBox and an ImageButton, they are intended to be viewed and accessible on all content sites. Here’s the aspx code in Site.Master:

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageBtn" runat="server" ImageUrl="~/Image.png"
  PostBackUrl="~/Result.aspx"></asp:ImageButton>

Clicking the button should redirect the visitor to Result.aspx, which it does.

Result.aspx.cs has the following in the Page_Load event:

    protected void Page_Load(object sender, EventArgs e)
    {
        TextBox txbx = this.Master.FindControl("TextBox1") as TextBox;
        if (txbx != null)
        {
            Label1.Text = "Value: " + txbx.Text;
        }
        else
        {
            Label1.Text = "TextBox seems to be null";
        }
    }

The weird behavior appears when the image button is clicked the first time. The visitor gets this information from the page “Value: ” (i.e an empty string “”), even though a value was entered in TextBox1. The subsequent clicks presents the value(s) correctly, e.g “Value: SomeText”.

Why doesn’t the value “come along” the first time?

Is there a better way to ensure that?

  • The visitor is redirected to Result.aspx AND
  • that the value is “registered” and can be handled in Result.aspx.cs AND
  • that a user will be redirected, if Result.aspx is entered without the use of the image buttons PostBackURL

I’ve tried IsPostBack but it seems to behave strangely when using a master page as previous page …

Very thankful for an answer!

Sincerely,

Mr Kay

  • 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-09T19:39:41+00:00Added an answer on June 9, 2026 at 7:39 pm

    If you are using PostBackURL on your ImageButton on the master page and come from another page you must use:

    PreviousPage.Master.FindControl("TextBox1") as TextBox;

    If you are on the PostBackURL page and click your ImageButton, you need to use

    Master.FinControl("TextBox1") as TextBox;

    (PreviousPage would be null in this case)

    you could use something like this:

    var txbx = PreviousPage == null ?
        Master.FindControl("TextBox1") as TextBox :
        PreviousPage.Master.FindControl("TextBox1") as TextBox;
    

    See: http://msdn.microsoft.com/en-us/library/system.web.ui.page.previouspage(v=vs.100).aspx
    at the Remarks section.

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

Sidebar

Related Questions

I am validing the default.aspx(uses master page) of my web site, however; I am
I have a web site in asp.net that uses a master page. In this
Consider a website that uses master pages and web user controls excessively. (1)Master ->
Web-development novice here. I want to try implementing a simple web site that uses
Recently I just got assigned a project to develop a web application/site that uses
We have set up a web site for a client who uses Google Apps
I want to publish a web site on Amazon's servers, that: Runs CakePHP Uses
Say, if I write a web site using ASP.NET that uses the SQL Server
I'm working on an ASP .NET 2.0 site which uses a Web Application project
I'm trying to include jQuery in an ASP.NET web site that also uses DexExpress

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.