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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:28:52+00:00 2026-06-16T16:28:52+00:00

Currently, I have a text box and a button on my master page for

  • 0

Currently, I have a text box and a button on my master page for entering and submitting a search string. The search is internal to my website. The user would enter the search string then click on the search button. The search button redirects to the search results page. When the search results page is loaded, it currently searches through the controls on the previous page to find the search string textbox to retrieve the search string.

This all works fine except when a search is entered from the log-in page due to an exception: The current user is not allowed to access the previous page.

So I’m wondering what might be a better way to retrieve the search string. I’d prefer not to clutter the redirect url with it. I’m not adverse to storing it in the Session collection but am having trouble figuring out how to get it there before the Page load event occurs.

Below is the pertinet code:

From the master page:

<asp:TextBox ID="SearchTextBox" runat="server" />
<asp:ImageButton ID="SearchButton" runat="server" Text="Search" PostBackUrl="~/Search.aspx" ImageUrl="~/Graphics/btn_search.png" ImageAlign="AbsMiddle" />

From the search results page:

private string getSearchTextBoxText(Control ctrl)
{
    if (ctrl.HasControls())
    {
        foreach (Control child in ctrl.Controls)
        {
            string s = getSearchTextBoxText(child);

            if (s != null)
                return s;
        }
    }
    else if (ctrl.ID == "SearchTextBox")
    {
        return ((TextBox)ctrl).Text;
    }

    return null;
}

protected void Page_Load(object sender, EventArgs e)
{
    log.Debug("Entering " + MethodBase.GetCurrentMethod().Name);
    string lastSearchText = Label1.Text;
    string searchText = null;

    try
    {
        searchText = PreviousPage != null ? getSearchTextBoxText(PreviousPage) : getSearchTextBoxText(this);
    }
    catch(Exception ex)
    {
        log.Error("Exception occurred attempting to retrieve the search string", ex);
    }
...
  • 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-16T16:28:53+00:00Added an answer on June 16, 2026 at 4:28 pm

    I was able to correct this by adding the following to the Web.config file in the Account directory:

    <location path="Login.aspx">
        <system.web>
            <authorization>
                <allow users="*"/>
            </authorization>
        </system.web>
    </location>
    

    Once that is added, then the previous page is accessible and the search string can be retrieved.

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

Sidebar

Related Questions

Greetings, In my current project, I have gridview, search button, text box for search,
I have a multiline text box, and I'd like to display the user's current
Currently I am doing this: I have text that looks like: Hello ${user.name}, this
I have a text box and a button, which is described with the HTML/CSS
I have a table which has both button and text box in some cells.
I Have a text box and a control button next to it.Clicking on the
I currently have 2 text fields where users enter full numbers, these are then
I currently have a text file that has the following: 1 Commercial & Enterprise
I currently have 6 100mb+ PDF documents which have searchable text layer enabled. However
I currently have a small text game I've written in Java that utilizes System.out.print();

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.