1

有什么方法可以让我跟踪按钮单击哪个网页。

例如 Default1.aspx button1 点击

然后在我的日志文件中。我的日志文件将记录 button1 在 default1 页面中单击。

是否可以在 global.asax 文件的 beginrequest 事件中执行此操作?请指导我一个解决方案。

这是我的 global.asax 代码

 protected void Application_Start(object sender, EventArgs e)
    {

        // Set logfile name and application name variables

        string l4net = Server.MapPath("~/log4Net.config");
        log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(l4net));


    }

    protected void Application_BeginRequest(object sender, EventArgs e)
    {
        //What should i code here???

    }

任何帮助深表感谢

4

1 回答 1

0

是的,你当然可以做到。

您可以使用获取当前页面

var page = HttpContext.Current.Request.Url;

并且按钮存在于事件目标中

var button = HttpContext.Current.Request.Params["__EVENTTARGET"];

这将为您获取控件的 ClientID,但您应该能够从中提取控件 ID。

于 2012-09-03T04:07:40.300 回答