如何使用properties.settings.default上述<脚本> _Layout.cshtml [英] How to use properties.settings.default in <script> _Layout.cshtml

查看:129
本文介绍了如何使用properties.settings.default上述<脚本> _Layout.cshtml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试使用普通properties.settings我们CSHTML布局页。
VaR的设置是在标签(jQuery的)

我们能够达到 properties.settings.default.OurSetting 在我们的控制器。

我们看了看这么几个问题,但他们只给了例子在控制器中去实现它。

例如:<一href=\"http://stackoverflow.com/questions/453161/best-practice-to-save-application-settings-in-a-windows-application\">Best实践保存在Windows应用程序设置窗体应用程序

如何使用Visual C#

的http:/ /www.$c$cproject.com/Articles/17659/How-To-Use-the-Settings-Class-in-C

因此​​,我们试图做的。

  VAR值='@(MyProjectName.Properties.Settings.Default.OurSetting)'

但是,上面写着名字属性并不在目前的情况下存在。

修改

我们使用来自web.config中的appSettings第一,但因为我们希望能够更改设置W / O重新加载应用程序。


解决方案

更改访问修饰符从内部到公众Settings.Designer的。

We are trying to use the general properties.settings in our cshtml layout page. The var setting is in the tag (jQuery)

We are able to reach the properties.settings.default.OurSetting in our controller.

We looked at a few questions on SO but they only gave examples to reach it in the controller.

ex: Best practice to save application settings in a Windows Forms Application

How to use settings in Visual C#

http://www.codeproject.com/Articles/17659/How-To-Use-the-Settings-Class-in-C

So we are tried to do

var setting = '@(MyProjectName.Properties.Settings.Default.OurSetting)'

But that says the name Properties does not exist in the current context.

EDIT

We used the appSettings from the web.config first but because we want to be able to change the setting w/o reloading the app.

解决方案

Change Access Modifier of the Settings.Designer from internal to public.

这篇关于如何使用properties.settings.default上述&lt;脚本&GT; _Layout.cshtml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆