我想隐藏输入
(new { htmlAttributes = new { @type = "number", @min = "1", @max="99", @placeholder = "Number of ???" } })
当 post 方法被实际触发时,我希望它之后隐藏输入。
//cshtml
@using (@Html.BeginForm("ConfirmOrder", "Home", FormMethod.Post))
{
@Html.EditorFor(model => model.Number, new { htmlAttributes = new { @type = "number", @min = "1", @max = "99", @placeholder = "Number of ???" } })
<input type="submit" value="Confirm" />
}
//cshtml.cs代码
public class DetailsModel : PageModel
{
private readonly ShopDashboard.Models.ShopDashboardContext _context;
public DetailsModel(ShopDashboard.Models.ShopDashboardContext context)
{
_context = context;
}
public int Number { get; set; }
public Order Order { get; set; }
public async Task<IActionResult> OnGetAsync(string id)
{
if (id == null)
{
return NotFound();
}
Order = await Task.Run(() => Post.GetOrders().FirstOrDefault(m => m.Id == id));
if (Order == null)
{
return NotFound();
}
return Page();
}
public async Task<IActionResult> OnPostAsync(string id, int Number = -1)
{
if (id == null)
{
return NotFound();
}
Order = await Task.Run(() => Post.method().FirstOrDefault(m => m.Id == id));
if (Order != null)
{
IActionResult result;
if (Number == -1)
{
result = new OkObjectResult(JsonConvert.DeserializeObject(Post.method().Content));
return result;
}
MediaTypeHeaderValue mediaTypeHeaderValue = new MediaTypeHeaderValue("application/pdf");
IRestResponse response = Post.method();
result = new ContentResult() { Content = response.Content };
if (response.IsSuccessful)
{
FileContentResult contentResult = new FileContentResult(response.RawBytes, mediaTypeHeaderValue.MediaType)
{
FileDownloadName = "???" + response.Headers
.Where(header => header.Name == "Content-Disposition").First()
.Value.ToString().Split("=")[1].Split("?").First() + ".pdf"
};
result = contentResult;
}
return result;
}
return Page();
}