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

47 lines
1.6 KiB
Markdown
Raw Normal View History

2016-10-29 01:35:15 +08:00
---
2016-11-17 08:24:57 +08:00
title: Adding Search | Microsoft Docs
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-11-18 04:13:02 +08:00
keywords: ASP.NET Core,
2016-10-29 01:35:15 +08:00
ms.author: riande
manager: wpickett
ms.date: 03/07/2017
2016-10-29 01:35:15 +08:00
ms.topic: article
ms.assetid: d69e5529-8ef6-4628-855d-200206d962b9
2016-11-17 08:24:57 +08:00
ms.technology: aspnet
ms.prod: asp.net-core
2016-10-29 01:35:15 +08:00
uid: tutorials/first-mvc-app/search
---
[!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
[!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
[!INCLUDE[adding-model](../../includes/mvc-intro/search3.md)]
2016-10-29 01:35:15 +08:00
2016-11-10 13:17:21 +08:00
>[!div class="step-by-step"]
[Previous](controller-methods-views.md)
[Next](new-field.md)