@namespace Oqtane.Themes.Controls @using System.Net @using Microsoft.AspNetCore.Http @inherits ThemeControlBase @inject IStringLocalizer Localizer @inject NavigationManager NavigationManager @inject IHttpContextAccessor HttpContext @if (_searchResultsPage != null) {
} @code { private Page _searchResultsPage; private string _keywords = ""; [Parameter] public string CssClass { get; set; } [Parameter] public string Position { get; set; } = "Main"; [Parameter] public string SearchResultPagePath { get; set; } = "search"; protected override void OnInitialized() { if(!string.IsNullOrEmpty(SearchResultPagePath)) { _searchResultsPage = PageState.Pages.FirstOrDefault(i => i.Path == SearchResultPagePath); } } protected override void OnParametersSet() { } private void PerformSearch() { var keywords = HttpContext.HttpContext.Request.Form["keywords"]; if (!string.IsNullOrEmpty(keywords) && _searchResultsPage != null) { var url = NavigateUrl(_searchResultsPage.Path, $"q={keywords}"); NavigationManager.NavigateTo(url); } } }