在剃须刀页面中,如何保留不属于表格的复选框的状态?
我的页面具有用于展开页面某些部分的复选框。这是在JavaScript中完成的客户端逻辑。
我想保留此特定页面的此复选框的状态。剃刀页可以自动执行此操作吗? 我尝试通过bool
属性 [bindproperty(supportsget = true)] 在pageModel
中然后重新加载(HTTP GET)复选框始终是错误的。
I have page that has checkbox that is used to expand/collapse some part of the page. This is client-side logic done in JavaScript.
I want to preserve the state of this checkbox for this particular page. Can Razor Pages do this automatically?
I tried by adding bool
property with [BindProperty(SupportsGet = true)]
in PageModel
but it doesn't work - when I check the checkbox and reload (HTTP GET) the checkbox is always false.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
猜测此切换功能是特定于用户的,并且您想在许多HTTP请求上坚持他们的选择,我建议使用客户端代码设置cookie,该代码是用户或更准确的设备 - 特定的,并且可以在需要的情况下持续使用,并且也可以在服务器上阅读。
Guessing that this toggle feature is user-specific, and that you want to persist their choice over a number of HTTP requests, I recommend setting a cookie using client-side code, which is user- or more accurately device-specific and can persist for as long as you need, and can be read on the server too.
不,由于您不将其发送到后端,因此不会显示它。
正如迈克所说,最好将其存储在客户端饼干或存储中。
更多详细信息,您可以参考以下代码:
No, since you don't send it to the backend it will not show it.
As Mike said, it better we could store it inside the client cookie or storage.
More details, you could refer to below codes: