I have an ASP.NET Core MVC Web Application
我有一个ASP.NET核心MVC Web应用程序
I have a vertical navigation menu that is 50px wide by default, but the user has the option to expand it to 200px by clicking a button that I give them. This button updates the css classes to make the menu wide.
我有一个垂直导航菜单,默认为50px宽,但用户可以通过单击我给他们的按钮将其扩展到200px。此按钮更新css类以使菜单更宽。
If the user expands it to 200px and then changes pages or causes a postback what are my options to persist that the user wants the menu at 200px.
如果用户将其扩展为200px,然后更改页面或导致回发,我可以选择保留用户希望菜单为200px的选项。
I am aware that I can probably use cookies, but I only want to do that if I absolutely have to.
我知道我可能会使用cookies,但如果我必须这样做,我只想这样做。
1 个解决方案
#1
1
You can store the width using localStorage, and get it when you load the page. (let's say, on jQuery's docuement ready). The best advantage of this is the fact that it will be persisted in the browser and you will not force the server to take the responsibility of remembering a view configuration.
您可以使用localStorage存储宽度,并在加载页面时获取它。 (让我们说,在jQuery的docuement准备就绪)。这样做的最大好处是它将持久存储在浏览器中,您不会强迫服务器负责记住视图配置。
#1
1
You can store the width using localStorage, and get it when you load the page. (let's say, on jQuery's docuement ready). The best advantage of this is the fact that it will be persisted in the browser and you will not force the server to take the responsibility of remembering a view configuration.
您可以使用localStorage存储宽度,并在加载页面时获取它。 (让我们说,在jQuery的docuement准备就绪)。这样做的最大好处是它将持久存储在浏览器中,您不会强迫服务器负责记住视图配置。