I have a search page that if there is results in the list it passes this list to a view. However if there are no results I want to send the searched text to a no results found view. How would I go about this?
You will need to have the searched text available as part of the model that is returned to the view. Then you have two options -
Using the RenderPartial will pass the returned view to the partial view so you can access the value you want from there.
Html.RenderPartial("PartialView");
Alternatively, you can pass the string as the model for the partial view using
Html.RenderPartial("PartialView", Model.SearchedText);
Which might make sense if you want to use the no results partial view with different models.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With