AspNetCore.Docs/aspnetcore/tutorials/first-mvc-app/search.md

45 lines
1.6 KiB
Markdown
Raw Normal View History

2016-10-29 01:35:15 +08:00
---
2017-07-01 07:47:15 +08:00
title: Adding Search
2016-10-29 01:35:15 +08:00
author: rick-anderson
description: Shows how to add search to simple ASP.NET Core MVC app
2016-10-29 01:35:15 +08:00
manager: wpickett
2018-01-29 23:21:31 +08:00
ms.author: riande
ms.date: 03/07/2017
ms.prod: asp.net-core
2018-01-29 23:21:31 +08:00
ms.technology: aspnet
ms.topic: get-started-article
2016-10-29 01:35:15 +08:00
uid: tutorials/first-mvc-app/search
---
2018-04-05 07:51:35 +08:00
[!INCLUDE [adding-model](../../includes/mvc-intro/search1.md)]
2016-10-29 01:35:15 +08:00
You can quickly rename the `searchString` parameter to `id` with the **rename** command. Right click on `searchString` **> Rename**.
![Contextual menu](search/_static/rename.png)
2016-10-29 01:35:15 +08:00
The rename targets are highlighted.
![Code editor showing the variable highlighted throughout the Index ActionResult method](search/_static/rename2.png)
2016-10-29 01:35:15 +08:00
Change the parameter to `id` and all occurrences of `searchString` change to `id`.
![Code editor showing the variable has been changed to id](search/_static/rename3.png)
2016-10-29 01:35:15 +08:00
2018-04-05 07:51:35 +08:00
[!INCLUDE [adding-model](../../includes/mvc-intro/search2.md)]
2016-10-29 01:35:15 +08:00
Notice how intelliSense helps us update the markup.
2016-10-29 01:35:15 +08:00
![Intellisense contextual menu with method selected in the list of attributes for the form element](search/_static/int_m.png)
2016-10-29 01:35:15 +08:00
![Intellisense contextual menu with get selected in the list of method attribute values](search/_static/int_get.png)
2016-10-29 01:35:15 +08:00
Notice the distinctive font in the `<form>` tag. That distinctive font indicates the tag is supported by [Tag Helpers](../../mvc/views/tag-helpers/intro.md).
![form tag with purple text](search/_static/th_font.png)
2016-10-29 01:35:15 +08:00
2018-04-05 07:51:35 +08:00
[!INCLUDE [adding-model](../../includes/mvc-intro/search3.md)]
2016-10-29 01:35:15 +08:00
2018-04-05 07:51:35 +08:00
> [!div class="step-by-step"]
> [Previous](controller-methods-views.md)
> [Next](new-field.md)