@Localizer 不适用于使用 asp-for 和值提交的特殊情况输入类型
@Localizer doesn't work on special case input type submit with asp-for and value
我的剃须刀页面上有一个按钮,我可以在其中向我的 post 方法提交一个值。
一切如我所愿
<input type="submit" value="Resend Link" asp-for="@resendLink" class="btn btn-primary" />
在我的 C# 中,我捕获了 post
上的值
public async Task<IActionResult> OnPostAsync(string resendLink)
现在我只想本地化按钮的语言
<input type="submit" value=@Localizer["Resend Link"] asp-for="@resendLink" class="btn btn-primary" />
定位器不起作用
如果我在没有 asp-for 标签的情况下使用它或者如果我用按钮标签声明它
<button type="submit" asp-for="@resendLink" value="ResendLink" class="btn btn-primary">@Localizer["Resend Link"]</button>
然而,它不再将值传输到我的 post 方法。
我如何本地化它?还有转移吗?
感谢您的帮助!
Asp.net 名称为 attribute.As 的核心绑定数据你说 It works if I use it without asp-for tag or if I declare it with button tag
。你可以删除 asp-for
标签并添加名称属性,如下所示:
<input type="submit" value=@Localizer["Resend Link"] name="resendLink" class="btn btn-primary" />
我的剃须刀页面上有一个按钮,我可以在其中向我的 post 方法提交一个值。 一切如我所愿
<input type="submit" value="Resend Link" asp-for="@resendLink" class="btn btn-primary" />
在我的 C# 中,我捕获了 post
上的值public async Task<IActionResult> OnPostAsync(string resendLink)
现在我只想本地化按钮的语言
<input type="submit" value=@Localizer["Resend Link"] asp-for="@resendLink" class="btn btn-primary" />
定位器不起作用
如果我在没有 asp-for 标签的情况下使用它或者如果我用按钮标签声明它
<button type="submit" asp-for="@resendLink" value="ResendLink" class="btn btn-primary">@Localizer["Resend Link"]</button>
然而,它不再将值传输到我的 post 方法。
我如何本地化它?还有转移吗?
感谢您的帮助!
Asp.net 名称为 attribute.As 的核心绑定数据你说 It works if I use it without asp-for tag or if I declare it with button tag
。你可以删除 asp-for
标签并添加名称属性,如下所示:
<input type="submit" value=@Localizer["Resend Link"] name="resendLink" class="btn btn-primary" />