CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2007
    Posts
    24

    Problem populating the controls in a Master page

    Hello,

    I am working on a site which has to have a search form on every page. So I decided to put it in a Master page. Then on the submit button I place the following property:
    Code:
    PostBackUrl="~/Search.aspx"
    From a page (say the Default.aspx one) I access the search form controls with the following code:
    Code:
    TextBox tbPriceFrom = (TextBox)Master.FindControl("tbPriceFrom");
    TextBox tbPriceTo = (TextBox)Master.FindControl("tbPriceTo");
    My problem is that the controls are not populated with the entered from the user data.

    Please, help.

    Thanks.

  2. #2
    Join Date
    Sep 2007
    Posts
    24

    Re: Problem populating the controls in a Master page

    I found the solution. There is a PreviousPage property (only available when a cross-page posting occurs). This property contains the view state of the previous page. So instead of calling
    Code:
    TextBox tbPriceFrom = (TextBox)Master.FindControl("tbPriceFrom");
    TextBox tbPriceTo = (TextBox)Master.FindControl("tbPriceTo");
    we need to call
    Code:
    TextBox tbPriceFrom = (TextBox)PreviousPage.Master.FindControl("tbPriceFrom");
    TextBox tbPriceTo = (TextBox)PreviousPage.Master.FindControl("tbPriceTo");

  3. #3
    Join Date
    Jun 2010
    Location
    Cairo, Egypt
    Posts
    17

    Re: Problem populating the controls in a Master page


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured