8 Building forms with Tag Helpers

 

This chapter covers

  • Building forms easily with Tag Helpers
  • Generating URLs with the Anchor Tag Helper
  • Using Tag Helpers to add functionality to Razor

In chapter 7 you learned about Razor templates and how to use them to generate the views for your application. By mixing HTML and C#, you can create dynamic applications that can display different data based on the request, the logged-in user, or any other data you can access.

Displaying dynamic data is an important aspect of many web applications, but it’s typically only half of the story. As well as displaying data to the user, you often need the user to be able to submit data back to your application. You can use data to customize the view, or to update the application model by saving it to a database, for example. For traditional web applications, this data is usually submitted using an HTML form.

In chapter 6 you learned about model binding, which is how you accept the data sent by a user in a request and convert it into C# objects that you can use in your Razor Pages. You also learned about validation, and how important it is to validate the data sent in a request. You used DataAnnotations attributes to define the rules associated with your models, as well as other associated metadata like the display name for a property.

8.1 Catering to editors with Tag Helpers

 
 
 

8.2 Creating forms using Tag Helpers

 

8.2.1 The Form Tag Helper

 
 

8.2.2 The Label Tag Helper

 
 
 
 

8.2.3 The Input and Textarea Tag Helpers

 
 
 

8.2.4 The Select Tag Helper

 

8.2.5 The Validation Message and Validation Summary Tag Helpers

 
 
 

8.3 Generating links with the Anchor Tag Helper

 

8.4 Cache-busting with the Append Version Tag Helper

 
 
 

8.5 Using conditional markup with the Environment Tag Helper

 
 

Summary

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest