如何创建可以在整个asp.net项目中访问的全局变量? [英] How to crate global variable that can access in entire asp.net project?

查看:329
本文介绍了如何创建可以在整个asp.net项目中访问的全局变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个变量,其中包含一个动态字符串,我可以在javascript中访问整个asp.net项目,是否有人能如何做到这一点?????

I’m trying to create a variable that holds a dynamic string that I can access throughout the entire asp.net project in javascript, does anyone of how I can do this?????

推荐答案

您好,



试试这个...



< a href =http://msdn.microsoft.com/en-us/library/ms952597.aspx> http://msdn.microsoft.com/en-us/library/ms952597.aspx [< a href =http://msdn.microsoft.com/en-us/library/ms952597.aspxtarget =_ blanktitle =新窗口> ^ ]


你可以这样做



在母版页中创建一个隐藏的字段。

将动态值存储在后面的代码中。 。你可以访问所有的ASPX页面(javascript)

希望它有效..
you can do like this

Create a hidden Field in the master page.
Store the dynamic value in the code behind .. and you can access in all the ASPX pages ( javascript )
Hope it works ..


你可以使用session或cookie。你也可以使用viewstate。但它只能在几页内完成。
You can use session or cookie.you also can use viewstate.but it works in few pages.


这篇关于如何创建可以在整个asp.net项目中访问的全局变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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