如何在aspx页面中获取Global.asax变量? [英] How to get Global.asax variable in aspx page ?

查看:400
本文介绍了如何在aspx页面中获取Global.asax变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi
我正在创建网站,因为我将使用Global.asax,在Application_Start方法的该页面中,我将在字符串中声明捕获日期时间和秒,该字符串需要进入aspx页面。下面是我声明的地方及其价值的代码。





Hi I am creating website,in that i will use Global.asax ,in that page in Application_Start method i will declare in string for capture date time and secs,that string in need to get in aspx page.Below is my code for where i declare and its value.


Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
 Dim Globaltime As String = Date.Now.ToString("ddMMMyyyyhhmmss")
End Sub







在上面我需要我们所有aspx页面中的Globalpath。如何在aspx页面中获取此值。





请尽快回复



问候

Aravind




In above i need to use Globalpath in all aspx page.So how to get this value in aspx page.


Pls reply asap

Regards
Aravind

推荐答案

Hello Aravind,



想我在网上找到了一个解决方案。

看看这个。



Hello Aravind,

think I found a solution on Web.
Take a look this.

public class Global : System.Web.HttpApplication
{
   public static string testVar;

   protected void Application_Start(object sender, EventArgs e)
   {
      testVar = "This is a test";
   }
}





调用变量:





Calling the variable:

Label5.Text = Global.testVar;


这篇关于如何在aspx页面中获取Global.asax变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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