⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logdemo.aspx

📁 asp.net经典案例资料
💻 ASPX
字号:
<%@ Import Namespace="System.Diagnostics" %>
<%@ Page Language="C#" Debug="true" %>
<html>
  <head>
    <title>Log Demo</title>
    <script language="C#" runat="server" >
    void OnInformation(object sender, EventArgs arg)
    {
      string logName = ConfigurationSettings.AppSettings["EventLogName"];
      string logSource = ConfigurationSettings.AppSettings["EventLogSource"];

      if(!(EventLog.SourceExists(logSource)))
      {
        EventLog.CreateEventSource(logSource, logName);
      }

      EventLog log = new EventLog();
      log.Source = logSource;
      log.WriteEntry(TextBox1.Text, EventLogEntryType.Information);
    }
    void OnException(object sender, EventArgs arg)
    {
      Exception e = new Exception(TextBox1.Text);
      throw(e);
    }
    </script>
  </head>

  <body>
  <form id="form1" runat="server">
    <h3>Log Demo</h3>
    日志内容<br/>
    <asp:TextBox id="TextBox1" runat="server"
        Columns="45" Rows="6" TextMode="MultiLine" />
    <hr/>
    <asp:Button id="ButtonInformation" runat="server" Text="记录日志" 
        OnClick="OnInformation"/>
    <asp:Button id="ButtonException" runat="server" Text="错误日志" 
        OnClick="OnException" />
  </form>
  </body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -