-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from haacked/haacked/50-submit-value
Propagate submit value
- Loading branch information
Showing
8 changed files
with
101 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
@page | ||
@model DemoWeb.Pages.Demos.SubmitButton | ||
|
||
@{ | ||
Layout = "Shared/_Layout"; | ||
} | ||
|
||
<fieldset> | ||
<legend>Required ASP.NET Checkboxes with hidden input</legend> | ||
|
||
<form method="post"> | ||
<div class="form-field"> | ||
<p> | ||
This simple test demonstrates that we ensure that submit buttons. | ||
</p> | ||
|
||
<input type="submit" asp-for="SubmitButtonValue" value="Input Type Submit" /> | ||
<input type="submit" value="Input Type Submit No Name" /> | ||
<input type="submit" name="SubmitButtonValue" /> | ||
<button type="submit" name="SubmitButtonValue" value="Submit That!">Button with name and value</button> | ||
|
||
<button type="submit" value="Submit That!">Button no name</button> | ||
<button type="submit" name="SubmitButtonValue">Button with name, no value</button> | ||
|
||
@if (Model.SubmitButtonValue is not null) { | ||
<span class="results"> | ||
The submitted button value is "@Model.SubmitButtonValue". | ||
</span> | ||
|
||
<p>The submitted form collection:</p> | ||
<table class="form-data"> | ||
@foreach (var item in Request.Form) { | ||
<tr> | ||
<th>@item.Key</th> | ||
<td>@item.Value</td> | ||
</tr> | ||
} | ||
</table> | ||
} | ||
|
||
|
||
</div> | ||
</form> | ||
</fieldset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace DemoWeb.Pages.Demos; | ||
|
||
public class SubmitButton : PageModel | ||
{ | ||
[BindProperty] | ||
[Required] | ||
public string? SubmitButtonValue { get; set; } | ||
|
||
public void OnPost() | ||
{ | ||
SubmitButtonValue ??= "Form submitted, but button value not submitted"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters