Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Add TagHelperSample.Web #1289

Merged
merged 2 commits into from
Oct 10, 2014
Merged

Add TagHelperSample.Web #1289

merged 2 commits into from
Oct 10, 2014

Conversation

dougbu
Copy link
Member

@dougbu dougbu commented Oct 8, 2014

Add Tag Helper sample, #1242

<validation-summary tag="div"/>

@* element will have correct name and id attributes for Id property. but will submit a constant value. *@
<input type="hidden" for="Id" value="0" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file isn't much different from Edit.cshtml but I only use a user-specified HTML attributes (that helper would normally generate) here. suspect "class" attribute would be merged but all other user-specified HTML attributes would just win.

@dougbu
Copy link
Member Author

dougbu commented Oct 8, 2014

<div class="form-group">
<label for="DateOfBirth" class="control-label col-md-2" />
<div class="col-md-10">
<input type="date" for="DateOfBirth" format="{0:d}" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • at least initially, input tag helper will ignore the "format" bound attribute if "type" is checkbox, hidden, password, or radio.
  • type="radio" (not in this sample) needs a value to compare to the expression and the "value" HTML attribute Just Works(tm). so under the covers, that may be the only case where MVC tag helpers use TagHelperContext.AllAttributes

@NTaylorMullen
Copy link
Contributor

Should showcase <form> with one or more of its allowed attributes.

@NTaylorMullen
Copy link
Contributor

Would be nice to see a _Layout with a few anchor tag helpers (to show they can be used there). They're perfect for navigation.

<h2>Create</h2>

<form>
@Html.AntiForgeryToken()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at one point we discussed adding this as a parameter to <form>, something like:

<form addAntiForgeryToken="true">

I could just be misremembering though. /cc @DamianEdwards

@NTaylorMullen
Copy link
Contributor

🐃

<input type="hidden" for="Id" value="0" />

<div class="form-group">
<label for="Name" class="control-label col-md-2" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since <label/> already has a "for" attribute, we should probably use another name for the <label/> / <input/> / <select/> / <textarea/> expression bound attribute. @DamianEdwards any suggestions?

@dougbu
Copy link
Member Author

dougbu commented Oct 8, 2014

Should showcase

with one or more of its allowed attributes.

👌

Would be nice to see a _Layout with a few anchor tag helpers (to show they can be used there). They're perfect for navigation.

👎 already using <a/> and this sample doesn't need another file

🐃

what does the water buffalo mean?

@NTaylorMullen
Copy link
Contributor

Buffalo is my version of ⌚ , trying to be a trend setter :trollface:. I was thinking a _Layout would showcase that these things are useable in those pages but did not affect the resulting pages underneath it.

@dougbu
Copy link
Member Author

dougbu commented Oct 9, 2014

Rebased and updated

@yishaigalatzer @Eilon @DamianEdwards please let @NTaylorMullen and I know if the sample and its comments misses anything from our meeting.

<label for="YearsEmployeed" class="control-label col-md-2" />
<div class="col-md-10">
@* <select/> tag helper has ContentBehavior.Append -- items render after static options *@
<select for="YearsEmployeed" items="(IEnumerable<SelectListItem>)ViewBag.Items" size="2" class="form-control">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"items" attribute needn't be so ugly. I just didn't switch from User to UserViewModel in this sample.

@NTaylorMullen NTaylorMullen force-pushed the TagHelpersFeature branch 2 times, most recently from d948242 to b68fae9 Compare October 9, 2014 19:52
@dougbu dougbu force-pushed the taghelper.sample.1242 branch from 9f0d7ad to 753c3ca Compare October 9, 2014 20:29
@dougbu dougbu force-pushed the taghelper.sample.1242 branch from 753c3ca to 82cce78 Compare October 9, 2014 22:12
@NTaylorMullen
Copy link
Contributor

:shipit:

@dougbu dougbu merged commit 82cce78 into TagHelpersFeature Oct 10, 2014
@dougbu dougbu deleted the taghelper.sample.1242 branch October 10, 2014 05:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants