简体   繁体   中英

Make connection to function on defaul.aspx from global.asax

I'm having a void in my Global.asax, looking like this

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.

So my question is, how do I get a connection to the textbox from Global.asax?

You won't be able to get this from your Application_Start() method in the Global.asax file. That method is called once when the application is started. Here is an excerpt from MSDN:

Called when the first resource (such as a page) in an ASP.NET application is requested. The Application_Start method is called only one time during the life cycle of an application. 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.

The textbox or any control on any page will not be rendered at this point regardless.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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