从 global.asax 连接到 defaul.aspx 上的函数
我的 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)
{
}
}
}
我需要的是让 Application_Start 检查 defaul.aspx 上的文本框是否为空。
所以我的问题是,如何从 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将无法从 Global.asax 文件中的
Application_Start()
方法获取此信息。该方法在应用程序启动时调用一次。以下是 MSDN 的摘录:当请求 ASP.NET 应用程序中的第一个资源(例如页面)时调用。 Application_Start 方法在应用程序的生命周期中仅被调用一次。您可以使用此方法执行启动任务,例如将数据加载到缓存中并初始化静态值。
您应该在应用程序启动期间仅设置静态数据。不要设置任何实例数据,因为它仅对创建的 HttpApplication 类的第一个实例可用。
此时,任何页面上的文本框或任何控件都不会呈现。
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.