Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 Razor Pages 应用程序 (ASP.NET Core)。
有没有办法从 JavaScript 向验证摘要写入消息?它是否已格式化(红色等)?
验证摘要标签助手将 CSS 类添加到呈现验证摘要的 div:validation-summary-errors。您可以使用它(或添加到 div 的任何其他选择器)在 JavaScript 中获取对 div 的引用:
validation-summary-errors
var summary = document.querySelector('.validation-summary-errors'); summary.innerHTML = "<p style='color:red;'>Oops!</p>";