简体   繁体   English

从global.asax连接到defaul.aspx上的功能

[英]Make connection to function on defaul.aspx from global.asax

I'm having a void in my Global.asax, looking like this 我的Global.asax中有一个空白,看起来像这样

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace TestCenter_Galleri
{
    public class Global : System.Web.HttpApplication
    {
        void Application_Start(object sender, EventArgs e)
        {
        }
    }
}

What I need is to have Application_Start to check whether or not a textbox on defaul.aspx is empty or not. 我需要的是Application_Start来检查defaul.aspx上的文本框是否为空。

So my question is, how do I get a connection to the textbox from Global.asax? 所以我的问题是,如何从Global.asax获取到文本框的连接?

You won't be able to get this from your Application_Start() method in the Global.asax file. 您将无法从Global.asax文件中的Application_Start()方法获得此信息。 That method is called once when the application is started. 启动应用程序后,该方法将被调用一次。 Here is an excerpt from MSDN: 这是MSDN的摘录:

Called when the first resource (such as a page) in an ASP.NET application is requested. 当请求ASP.NET应用程序中的第一个资源(例如页面)时调用。 The Application_Start method is called only one time during the life cycle of an application. 在应用程序的生命周期中,仅一次调用Application_Start方法。 You can use this method to perform startup tasks such as loading data into the cache and initializing static values. 您可以使用此方法执行启动任务,例如将数据加载到缓存中并初始化静态值。

You should set only static data during application start. 您应该在应用程序启动期间仅设置静态数据。 Do not set any instance data because it will be available only to the first instance of the HttpApplication class that is created. 不要设置任何实例数据,因为它仅对所创建的HttpApplication类的第一个实例可用。

The textbox or any control on any page will not be rendered at this point regardless. 无论何时,此文本框或任何页面上的任何控件都不会呈现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM