Reputation: 71
I'm trying to create a search box that leads to another page to execute the search. E.g. search in Inquirypage --> get result in Listpage. How do I get the value from Inquiry page to list page since they're not in the same class. Can i get some insights? Thank you
Search button from first page:
public async void FromBPSearchTap(object sender, EventArgs e)
{
var BPSearch = Customer.Text;
if (string.IsNullOrWhiteSpace(BPSearch))
{
BPSearch = string.Empty;
}
BPSearch = BPSearch.ToUpperInvariant();
}
Upvotes: 0
Views: 44
Reputation: 929
Pass the string as a parameter to the next page's constructor.
Sample code as below:
In your InquiryPage.xaml.cs
private async void FromBPSearchTap(object sender, System.EventArgs e)
{
//...
//your code with BPSearch
await Navigation.PushAsync(new ListPage(BPSearch));
}
In your next ListPage.xaml.cs
string _searchText
public ListPage(string searchText)
{
InitializeComponent();
_searchText = searchText; //have your text in ListPage now
}
Upvotes: 2