|
-
May 27th, 2010, 12:11 PM
#1
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.
-
May 27th, 2010, 11:18 PM
#2
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");
-
June 25th, 2010, 07:05 PM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|